Skip to content

Instantly share code, notes, and snippets.

@will-ockmore
Created September 29, 2016 08:51
Show Gist options
  • Save will-ockmore/932e9c603f13712c17b2ebe12ba12f62 to your computer and use it in GitHub Desktop.
Save will-ockmore/932e9c603f13712c17b2ebe12ba12f62 to your computer and use it in GitHub Desktop.
Migration to create new models in new app
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
from django.conf import settings
import django.db.models.deletion
import django.utils.timezone
import uuid
class Migration(migrations.Migration):
dependencies = [
('activities', '0012_merge'),
('users', '0012_auto_20160928_1542'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('practices', '0012_auto_20160926_0915'),
]
state_operations = [
migrations.CreateModel(
name='HistoricalStaffToDo',
fields=[
('id', models.UUIDField(default=uuid.uuid4, editable=False, db_index=True)),
('created', models.DateTimeField(default=django.utils.timezone.now, db_index=True)),
('modified', models.DateTimeField(default=django.utils.timezone.now)),
('is_completed', models.BooleanField(default=False)),
('entry', models.TextField(blank=True)),
('memo', models.TextField(blank=True)),
('start_date', models.DateTimeField(null=True)),
('end_date', models.DateTimeField(null=True)),
('completed_date', models.DateTimeField(null=True)),
('title', models.CharField(max_length=255)),
('deadline', models.DateTimeField(null=True)),
('is_urgent', models.BooleanField(default=False)),
('type', models.CharField(max_length=50, null=True)),
('info', models.TextField(blank=True)),
('completion_notes', models.TextField(default='', blank=True)),
('reminder', models.CharField(default='NONE', choices=[('NONE', 'None'), ('ONE_DAY_BEFORE', '1 day before'), ('TWO_DAYS_BEFORE', '2 days before'), ('THREE_DAYS_BEFORE', '3 days before'), ('ONE_WEEK_BEFORE', '1 week before'), ('TWO_WEEKS_BEFORE', '2 weeks before'), ('ONE_MONTH_BEFORE', '1 month before')], max_length=25)),
('second_reminder', models.CharField(default='NONE', choices=[('NONE', 'None'), ('ONE_DAY_BEFORE', '1 day before'), ('TWO_DAYS_BEFORE', '2 days before'), ('THREE_DAYS_BEFORE', '3 days before'), ('ONE_WEEK_BEFORE', '1 week before'), ('TWO_WEEKS_BEFORE', '2 weeks before'), ('ONE_MONTH_BEFORE', '1 month before')], max_length=25)),
('history_id', models.AutoField(primary_key=True, serialize=False)),
('history_date', models.DateTimeField()),
('history_type', models.CharField(choices=[('+', 'Created'), ('~', 'Changed'), ('-', 'Deleted')], max_length=1)),
('activity', models.ForeignKey(to='activities.Activity', db_constraint=False, related_name='+', null=True, on_delete=django.db.models.deletion.DO_NOTHING, blank=True)),
('completed_by', models.ForeignKey(to='users.StaffDetail', db_constraint=False, related_name='+', null=True, on_delete=django.db.models.deletion.DO_NOTHING, blank=True)),
('created_by', models.ForeignKey(to='users.StaffDetail', db_constraint=False, related_name='+', null=True, on_delete=django.db.models.deletion.DO_NOTHING, blank=True)),
('history_user', models.ForeignKey(to=settings.AUTH_USER_MODEL, related_name='+', null=True, on_delete=django.db.models.deletion.SET_NULL)),
('practice', models.ForeignKey(to='practices.Practice', db_constraint=False, related_name='+', null=True, on_delete=django.db.models.deletion.DO_NOTHING, blank=True)),
('staff', models.ForeignKey(to='users.StaffDetail', db_constraint=False, related_name='+', null=True, on_delete=django.db.models.deletion.DO_NOTHING, blank=True)),
],
options={
'ordering': ('-history_date', '-history_id'),
'verbose_name': 'historical staff to do',
'get_latest_by': 'history_date',
'db_table': 'todos_historicalstafftodos'
},
),
migrations.CreateModel(
name='StaffToDo',
fields=[
('id', models.UUIDField(default=uuid.uuid4, serialize=False, primary_key=True, editable=False, db_index=True)),
('created', models.DateTimeField(default=django.utils.timezone.now, db_index=True)),
('modified', models.DateTimeField(default=django.utils.timezone.now)),
('is_completed', models.BooleanField(default=False)),
('entry', models.TextField(blank=True)),
('memo', models.TextField(blank=True)),
('start_date', models.DateTimeField(null=True)),
('end_date', models.DateTimeField(null=True)),
('completed_date', models.DateTimeField(null=True)),
('title', models.CharField(max_length=255)),
('deadline', models.DateTimeField(null=True)),
('is_urgent', models.BooleanField(default=False)),
('type', models.CharField(max_length=50, null=True)),
('info', models.TextField(blank=True)),
('completion_notes', models.TextField(default='', blank=True)),
('reminder', models.CharField(default='NONE', choices=[('NONE', 'None'), ('ONE_DAY_BEFORE', '1 day before'), ('TWO_DAYS_BEFORE', '2 days before'), ('THREE_DAYS_BEFORE', '3 days before'), ('ONE_WEEK_BEFORE', '1 week before'), ('TWO_WEEKS_BEFORE', '2 weeks before'), ('ONE_MONTH_BEFORE', '1 month before')], max_length=25)),
('second_reminder', models.CharField(default='NONE', choices=[('NONE', 'None'), ('ONE_DAY_BEFORE', '1 day before'), ('TWO_DAYS_BEFORE', '2 days before'), ('THREE_DAYS_BEFORE', '3 days before'), ('ONE_WEEK_BEFORE', '1 week before'), ('TWO_WEEKS_BEFORE', '2 weeks before'), ('ONE_MONTH_BEFORE', '1 month before')], max_length=25)),
('activity', models.ForeignKey(to='activities.Activity', related_name='to_dos', null=True)),
('completed_by', models.ForeignKey(to='users.StaffDetail', related_name='completed_to_dos', null=True)),
('created_by', models.ForeignKey(to='users.StaffDetail', related_name='created_to_dos')),
('practice', models.ForeignKey(to='practices.Practice', related_name='to_dos', null=True)),
('staff', models.ForeignKey(to='users.StaffDetail', related_name='to_dos')),
],
options={
'abstract': False,
'db_table': 'todos_stafftodos'
},
),
]
operations = {
migrations.SeparateDatabaseAndState(state_operations=state_operations)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment