Added temporary datamigrations for photoalbum -> externallink (release preparation).
This commit is contained in:
parent
5f9ef08e3b
commit
caa69d6e6e
@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 3.2.7 on 2021-10-01 19:50
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('lostplaces', '0007_auto_20211001_1925'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='photoalbum',
|
||||||
|
name='linktype',
|
||||||
|
field=models.CharField(blank=True, max_length=20, null=True, verbose_name='link type'),
|
||||||
|
),
|
||||||
|
]
|
@ -0,0 +1,37 @@
|
|||||||
|
# Generated by Django 3.2.7 on 2021-10-01 20:13
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('lostplaces', '0008_photoalbum_linktype'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='ExternalLink',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('submitted_when', models.DateTimeField(auto_now_add=True, null=True, verbose_name='Submission date')),
|
||||||
|
('subclass', models.IntegerField(default=-1)),
|
||||||
|
('subclassid', models.IntegerField(default=-1)),
|
||||||
|
('url', models.URLField(verbose_name='URL')),
|
||||||
|
('label', models.CharField(max_length=100, verbose_name='link text')),
|
||||||
|
('linktype', models.CharField(blank=True, max_length=20, null=True, verbose_name='link type')),
|
||||||
|
('place', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='externallinks', to='lostplaces.place')),
|
||||||
|
('submitted_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='externallinks', to='lostplaces.explorer', verbose_name='Submitter')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'abstract': False,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='photoalbum',
|
||||||
|
name='externallink_ptr',
|
||||||
|
field=models.OneToOneField(auto_created=True, null=True, blank=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, serialize=False, to='lostplaces.externallink'),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
]
|
@ -0,0 +1,22 @@
|
|||||||
|
# Generated by Django 3.2.7 on 2021-10-01 20:32
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('lostplaces', '0009_photoalbum_externallink_interim'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
# insert data from subclass into parent class with subclass 'number' and primary key/id
|
||||||
|
migrations.RunSQL("""INSERT INTO lostplaces_externallink (submitted_when, url, label, place_id, submitted_by_id, subclass, subclassid)
|
||||||
|
SELECT submitted_when, url, label, place_id, submitted_by_id, 1, id
|
||||||
|
FROM lostplaces_photoalbum;"""
|
||||||
|
|
||||||
|
),
|
||||||
|
# update subclass primary key to point to parent class (notice composite key values):
|
||||||
|
migrations.RunSQL("UPDATE lostplaces_photoalbum SET externallink_ptr_id=lostplaces_externallink.id FROM lostplaces_externallink WHERE lostplaces_externallink.subclassid=lostplaces_photoalbum.id AND lostplaces_externallink.subclass=1;"
|
||||||
|
),
|
||||||
|
]
|
@ -0,0 +1,56 @@
|
|||||||
|
# Generated by Django 3.2.7 on 2021-10-01 22:48
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('lostplaces', '0010_photoalbum_externallink_datamigration'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='externallink',
|
||||||
|
name='subclass',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='externallink',
|
||||||
|
name='subclassid',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='photoalbum',
|
||||||
|
name='id',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='photoalbum',
|
||||||
|
name='label',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='photoalbum',
|
||||||
|
name='linktype',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='photoalbum',
|
||||||
|
name='place',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='photoalbum',
|
||||||
|
name='submitted_by',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='photoalbum',
|
||||||
|
name='submitted_when',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='photoalbum',
|
||||||
|
name='url',
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='photoalbum',
|
||||||
|
name='externallink_ptr',
|
||||||
|
field=models.OneToOneField(auto_created=True, default=-1, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='lostplaces.externallink'),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
]
|
Loading…
Reference in New Issue
Block a user