-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from citusdata/dropmodel-migration
fix migration for foreign keys when model doesn't exist anymore
- Loading branch information
Showing
5 changed files
with
127 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
django_multitenant/tests/migrations/0010_auto_20190517_1514.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.11 on 2019-05-17 15:14 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import django_multitenant.fields | ||
import django_multitenant.mixins | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('tests', '0009_auto_20190412_0839'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='TempModel', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('name', models.CharField(max_length=255)), | ||
('account', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='tests.Account', db_constraint=False)), | ||
], | ||
options={ | ||
'abstract': False, | ||
}, | ||
bases=(django_multitenant.mixins.TenantModelMixin, models.Model), | ||
), | ||
|
||
|
||
] |
22 changes: 22 additions & 0 deletions
22
django_multitenant/tests/migrations/0011_distribute_new_table.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.11 on 2019-05-17 15:14 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import django_multitenant.fields | ||
import django_multitenant.mixins | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('tests', '0010_auto_20190517_1514'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunSQL("ALTER TABLE tests_tempmodel DROP CONSTRAINT tests_tempmodel_pkey CASCADE;"), | ||
migrations.RunSQL("ALTER TABLE tests_tempmodel ADD CONSTRAINT tests_tempmodel_pkey PRIMARY KEY (account_id, id);"), | ||
migrations.RunSQL("SELECT create_distributed_table('tests_tempmodel', 'account_id');"), | ||
|
||
] |
33 changes: 33 additions & 0 deletions
33
django_multitenant/tests/migrations/0012_auto_20190517_1606.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.11 on 2019-05-17 16:06 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import django_multitenant.fields | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('tests', '0011_distribute_new_table'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='projectmanager', | ||
name='project', | ||
field=django_multitenant.fields.TenantForeignKey(on_delete=django.db.models.deletion.CASCADE, to='tests.Project'), | ||
), | ||
|
||
migrations.AddField( | ||
model_name='tempmodel', | ||
name='project', | ||
field=django_multitenant.fields.TenantForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='tests.Project'), | ||
), | ||
migrations.AlterField( | ||
model_name='tempmodel', | ||
name='account', | ||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='tests.Account'), | ||
), | ||
] |
24 changes: 24 additions & 0 deletions
24
django_multitenant/tests/migrations/0013_auto_20190517_1607.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.11 on 2019-05-17 16:07 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations | ||
import django.db.models.deletion | ||
import django_multitenant.fields | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('tests', '0012_auto_20190517_1606'), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name='tempmodel', | ||
name='project', | ||
), | ||
migrations.DeleteModel( | ||
name='TempModel', | ||
), | ||
] |