mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-13 14:44:29 -04:00
add migrations for SnapshotTag through model
This commit is contained in:
parent
7164fb961c
commit
cf2faecf61
19 changed files with 460 additions and 3 deletions
46
archivebox/core/migrations/0027_update_snapshot_ids.py
Normal file
46
archivebox/core/migrations/0027_update_snapshot_ids.py
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
# Generated by Django 5.0.6 on 2024-08-18 02:48
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
from datetime import datetime
|
||||||
|
from abid_utils.abid import ABID
|
||||||
|
|
||||||
|
|
||||||
|
def update_snapshot_ids(apps, schema_editor):
|
||||||
|
Snapshot = apps.get_model("core", "Snapshot")
|
||||||
|
num_total = Snapshot.objects.all().count()
|
||||||
|
print(f' Updating {num_total} Snapshot.id, Snapshot.uuid values in place...')
|
||||||
|
for idx, snapshot in enumerate(Snapshot.objects.all().only('abid').iterator()):
|
||||||
|
assert snapshot.abid
|
||||||
|
snapshot.uuid = ABID.parse(snapshot.abid).uuid
|
||||||
|
snapshot.save(update_fields=["uuid"])
|
||||||
|
assert str(ABID.parse(snapshot.abid).uuid) == str(snapshot.uuid)
|
||||||
|
if idx % 1000 == 0:
|
||||||
|
print(f'Migrated {idx}/{num_total} Snapshot objects...')
|
||||||
|
|
||||||
|
def update_archiveresult_ids(apps, schema_editor):
|
||||||
|
ArchiveResult = apps.get_model("core", "ArchiveResult")
|
||||||
|
num_total = ArchiveResult.objects.all().count()
|
||||||
|
print(f' Updating {num_total} ArchiveResult.id, ArchiveResult.uuid values in place... (may take an hour or longer for large collections...)')
|
||||||
|
for idx, result in enumerate(ArchiveResult.objects.all().only('abid').iterator()):
|
||||||
|
assert result.abid
|
||||||
|
result.uuid = ABID.parse(result.abid).uuid
|
||||||
|
result.save(update_fields=["uuid"])
|
||||||
|
assert str(ABID.parse(result.abid).uuid) == str(result.uuid)
|
||||||
|
if idx % 5000 == 0:
|
||||||
|
print(f'Migrated {idx}/{num_total} ArchiveResult objects...')
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0026_archiveresult_created_archiveresult_created_by_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RunPython(update_snapshot_ids, reverse_code=migrations.RunPython.noop),
|
||||||
|
migrations.RunPython(update_archiveresult_ids, reverse_code=migrations.RunPython.noop),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
19
archivebox/core/migrations/0028_alter_archiveresult_uuid.py
Normal file
19
archivebox/core/migrations/0028_alter_archiveresult_uuid.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
# Generated by Django 5.0.6 on 2024-08-18 04:28
|
||||||
|
|
||||||
|
import uuid
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0027_update_snapshot_ids'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='archiveresult',
|
||||||
|
name='uuid',
|
||||||
|
field=models.UUIDField(default=uuid.uuid4),
|
||||||
|
),
|
||||||
|
]
|
18
archivebox/core/migrations/0029_alter_archiveresult_id.py
Normal file
18
archivebox/core/migrations/0029_alter_archiveresult_id.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 5.0.6 on 2024-08-18 04:28
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0028_alter_archiveresult_uuid'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='archiveresult',
|
||||||
|
name='id',
|
||||||
|
field=models.BigIntegerField(primary_key=True, serialize=False, verbose_name='ID'),
|
||||||
|
),
|
||||||
|
]
|
18
archivebox/core/migrations/0030_alter_archiveresult_uuid.py
Normal file
18
archivebox/core/migrations/0030_alter_archiveresult_uuid.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 5.0.6 on 2024-08-18 05:00
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0029_alter_archiveresult_id'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='archiveresult',
|
||||||
|
name='uuid',
|
||||||
|
field=models.UUIDField(unique=True),
|
||||||
|
),
|
||||||
|
]
|
|
@ -0,0 +1,34 @@
|
||||||
|
# Generated by Django 5.0.6 on 2024-08-18 05:09
|
||||||
|
|
||||||
|
import uuid
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0030_alter_archiveresult_uuid'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='archiveresult',
|
||||||
|
name='id',
|
||||||
|
field=models.IntegerField(default=uuid.uuid4, primary_key=True, serialize=False, verbose_name='ID'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='archiveresult',
|
||||||
|
name='uuid',
|
||||||
|
field=models.UUIDField(default=uuid.uuid4, unique=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='snapshot',
|
||||||
|
name='uuid',
|
||||||
|
field=models.UUIDField(default=uuid.uuid4, unique=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='tag',
|
||||||
|
name='uuid',
|
||||||
|
field=models.UUIDField(default=uuid.uuid4, null=True, unique=True),
|
||||||
|
),
|
||||||
|
]
|
19
archivebox/core/migrations/0032_alter_archiveresult_id.py
Normal file
19
archivebox/core/migrations/0032_alter_archiveresult_id.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
# Generated by Django 5.0.6 on 2024-08-18 05:20
|
||||||
|
|
||||||
|
import core.models
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0031_alter_archiveresult_id_alter_archiveresult_uuid_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='archiveresult',
|
||||||
|
name='id',
|
||||||
|
field=models.BigIntegerField(default=core.models.rand_int_id, primary_key=True, serialize=False, verbose_name='ID'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 5.0.6 on 2024-08-18 05:34
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0032_alter_archiveresult_id'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='archiveresult',
|
||||||
|
old_name='id',
|
||||||
|
new_name='old_id',
|
||||||
|
),
|
||||||
|
]
|
|
@ -0,0 +1,41 @@
|
||||||
|
# Generated by Django 5.0.6 on 2024-08-18 05:37
|
||||||
|
|
||||||
|
import core.models
|
||||||
|
import uuid
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
from abid_utils.abid import ABID
|
||||||
|
|
||||||
|
|
||||||
|
def update_archiveresult_ids(apps, schema_editor):
|
||||||
|
ArchiveResult = apps.get_model("core", "ArchiveResult")
|
||||||
|
num_total = ArchiveResult.objects.all().count()
|
||||||
|
print(f' Updating {num_total} ArchiveResult.id, ArchiveResult.uuid values in place... (may take an hour or longer for large collections...)')
|
||||||
|
for idx, result in enumerate(ArchiveResult.objects.all().only('abid').iterator()):
|
||||||
|
assert result.abid
|
||||||
|
result.uuid = ABID.parse(result.abid).uuid
|
||||||
|
result.save(update_fields=["uuid"])
|
||||||
|
assert str(ABID.parse(result.abid).uuid) == str(result.uuid)
|
||||||
|
if idx % 2500 == 0:
|
||||||
|
print(f'Migrated {idx}/{num_total} ArchiveResult objects...')
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0033_rename_id_archiveresult_old_id'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='archiveresult',
|
||||||
|
name='old_id',
|
||||||
|
field=models.BigIntegerField(default=core.models.rand_int_id, serialize=False, verbose_name='ID'),
|
||||||
|
),
|
||||||
|
migrations.RunPython(update_archiveresult_ids, reverse_code=migrations.RunPython.noop),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='archiveresult',
|
||||||
|
name='uuid',
|
||||||
|
field=models.UUIDField(default=uuid.uuid4, primary_key=True, serialize=False, unique=True),
|
||||||
|
),
|
||||||
|
]
|
|
@ -0,0 +1,19 @@
|
||||||
|
# Generated by Django 5.0.6 on 2024-08-18 05:49
|
||||||
|
|
||||||
|
import uuid
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0034_alter_archiveresult_old_id_alter_archiveresult_uuid'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='archiveresult',
|
||||||
|
old_name='uuid',
|
||||||
|
new_name='id',
|
||||||
|
),
|
||||||
|
]
|
|
@ -0,0 +1,25 @@
|
||||||
|
# Generated by Django 5.0.6 on 2024-08-18 05:59
|
||||||
|
|
||||||
|
import core.models
|
||||||
|
import uuid
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0035_remove_archiveresult_uuid_archiveresult_id'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='archiveresult',
|
||||||
|
name='id',
|
||||||
|
field=models.UUIDField(default=uuid.uuid4, primary_key=True, serialize=False, unique=True, verbose_name='ID'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='archiveresult',
|
||||||
|
name='old_id',
|
||||||
|
field=models.BigIntegerField(default=core.models.rand_int_id, serialize=False, verbose_name='Old ID'),
|
||||||
|
),
|
||||||
|
]
|
18
archivebox/core/migrations/0037_rename_id_snapshot_old_id.py
Normal file
18
archivebox/core/migrations/0037_rename_id_snapshot_old_id.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 5.0.6 on 2024-08-18 06:08
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0036_alter_archiveresult_id_alter_archiveresult_old_id'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='snapshot',
|
||||||
|
old_name='id',
|
||||||
|
new_name='old_id',
|
||||||
|
),
|
||||||
|
]
|
18
archivebox/core/migrations/0038_rename_uuid_snapshot_id.py
Normal file
18
archivebox/core/migrations/0038_rename_uuid_snapshot_id.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 5.0.6 on 2024-08-18 06:09
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0037_rename_id_snapshot_old_id'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='snapshot',
|
||||||
|
old_name='uuid',
|
||||||
|
new_name='id',
|
||||||
|
),
|
||||||
|
]
|
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 5.0.6 on 2024-08-18 06:25
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0038_rename_uuid_snapshot_id'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='archiveresult',
|
||||||
|
old_name='snapshot',
|
||||||
|
new_name='snapshot_old',
|
||||||
|
),
|
||||||
|
]
|
34
archivebox/core/migrations/0040_archiveresult_snapshot.py
Normal file
34
archivebox/core/migrations/0040_archiveresult_snapshot.py
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
# Generated by Django 5.0.6 on 2024-08-18 06:46
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
def update_archiveresult_snapshot_ids(apps, schema_editor):
|
||||||
|
ArchiveResult = apps.get_model("core", "ArchiveResult")
|
||||||
|
Snapshot = apps.get_model("core", "Snapshot")
|
||||||
|
num_total = ArchiveResult.objects.all().count()
|
||||||
|
print(f' Updating {num_total} ArchiveResult.snapshot_id values in place... (may take an hour or longer for large collections...)')
|
||||||
|
for idx, result in enumerate(ArchiveResult.objects.all().only('snapshot_old_id').iterator()):
|
||||||
|
assert result.snapshot_old_id
|
||||||
|
snapshot = Snapshot.objects.get(old_id=result.snapshot_old_id)
|
||||||
|
result.snapshot_id = snapshot.id
|
||||||
|
result.save(update_fields=["snapshot_id"])
|
||||||
|
assert str(result.snapshot_id) == str(snapshot.id)
|
||||||
|
if idx % 5000 == 0:
|
||||||
|
print(f'Migrated {idx}/{num_total} ArchiveResult objects...')
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0039_rename_snapshot_archiveresult_snapshot_old'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='archiveresult',
|
||||||
|
name='snapshot',
|
||||||
|
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='archiveresults', to='core.snapshot', to_field='id'),
|
||||||
|
),
|
||||||
|
migrations.RunPython(update_archiveresult_snapshot_ids, reverse_code=migrations.RunPython.noop),
|
||||||
|
]
|
|
@ -0,0 +1,24 @@
|
||||||
|
# Generated by Django 5.0.6 on 2024-08-18 06:50
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0040_archiveresult_snapshot'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='archiveresult',
|
||||||
|
name='snapshot',
|
||||||
|
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.snapshot', to_field='id'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='archiveresult',
|
||||||
|
name='snapshot_old',
|
||||||
|
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='archiveresults_old', to='core.snapshot'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -0,0 +1,17 @@
|
||||||
|
# Generated by Django 5.0.6 on 2024-08-18 06:51
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0041_alter_archiveresult_snapshot_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='archiveresult',
|
||||||
|
name='snapshot_old',
|
||||||
|
),
|
||||||
|
]
|
|
@ -0,0 +1,20 @@
|
||||||
|
# Generated by Django 5.0.6 on 2024-08-18 06:52
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
import uuid
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0042_remove_archiveresult_snapshot_old'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='archiveresult',
|
||||||
|
name='snapshot',
|
||||||
|
field=models.ForeignKey(db_column='snapshot_id', on_delete=django.db.models.deletion.CASCADE, to='core.snapshot', to_field='id'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -0,0 +1,40 @@
|
||||||
|
# Generated by Django 5.0.6 on 2024-08-19 23:01
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
import uuid
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0043_alter_archiveresult_snapshot_alter_snapshot_id_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.SeparateDatabaseAndState(
|
||||||
|
database_operations=[
|
||||||
|
# No-op, SnapshotTag model already exists in DB
|
||||||
|
],
|
||||||
|
state_operations=[
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='SnapshotTag',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(primary_key=True, serialize=False)),
|
||||||
|
('snapshot', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='core.snapshot')),
|
||||||
|
('tag', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.tag')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'db_table': 'core_snapshot_tags',
|
||||||
|
'unique_together': {('snapshot', 'tag')},
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='snapshot',
|
||||||
|
name='tags',
|
||||||
|
field=models.ManyToManyField(blank=True, related_name='snapshot_set', through='core.SnapshotTag', to='core.tag'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
|
@ -61,7 +61,7 @@ class Tag(ABIDModel):
|
||||||
|
|
||||||
# id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=True)
|
# id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=True)
|
||||||
id = models.AutoField(primary_key=True, serialize=False, verbose_name='ID')
|
id = models.AutoField(primary_key=True, serialize=False, verbose_name='ID')
|
||||||
uuid = models.UUIDField(default=uuid.uuid4, editable=True, unique=True)
|
uuid = models.UUIDField(default=uuid.uuid4, null=True, unique=True)
|
||||||
abid = ABIDField(prefix=abid_prefix)
|
abid = ABIDField(prefix=abid_prefix)
|
||||||
|
|
||||||
|
|
||||||
|
@ -77,6 +77,10 @@ class Tag(ABIDModel):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def old_id(self):
|
||||||
|
return self.id
|
||||||
|
|
||||||
def slugify(self, tag, i=None):
|
def slugify(self, tag, i=None):
|
||||||
slug = slugify(tag)
|
slug = slugify(tag)
|
||||||
if i is not None:
|
if i is not None:
|
||||||
|
@ -115,9 +119,15 @@ class Tag(ABIDModel):
|
||||||
return f'/api/v1/docs#/Core%20Models/api_v1_core_get_tag'
|
return f'/api/v1/docs#/Core%20Models/api_v1_core_get_tag'
|
||||||
|
|
||||||
class SnapshotTag(models.Model):
|
class SnapshotTag(models.Model):
|
||||||
snapshot = models.OneToOneField('Snapshot', primary_key=True, on_delete=models.CASCADE, to_field='id')
|
id = models.AutoField(primary_key=True)
|
||||||
|
|
||||||
|
snapshot = models.OneToOneField('Snapshot', on_delete=models.CASCADE, to_field='old_id')
|
||||||
tag = models.ForeignKey(Tag, on_delete=models.CASCADE, to_field='id')
|
tag = models.ForeignKey(Tag, on_delete=models.CASCADE, to_field='id')
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
db_table = 'core_snapshot_tags'
|
||||||
|
unique_together = [('snapshot', 'tag')]
|
||||||
|
|
||||||
class Snapshot(ABIDModel):
|
class Snapshot(ABIDModel):
|
||||||
abid_prefix = 'snp_'
|
abid_prefix = 'snp_'
|
||||||
abid_ts_src = 'self.added'
|
abid_ts_src = 'self.added'
|
||||||
|
@ -134,9 +144,10 @@ class Snapshot(ABIDModel):
|
||||||
|
|
||||||
title = models.CharField(max_length=512, null=True, blank=True, db_index=True)
|
title = models.CharField(max_length=512, null=True, blank=True, db_index=True)
|
||||||
|
|
||||||
|
tags = models.ManyToManyField(Tag, blank=True, through=SnapshotTag, related_name='snapshot_set', through_fields=('snapshot', 'tag'))
|
||||||
|
|
||||||
added = models.DateTimeField(auto_now_add=True, db_index=True)
|
added = models.DateTimeField(auto_now_add=True, db_index=True)
|
||||||
updated = models.DateTimeField(auto_now=True, blank=True, null=True, db_index=True)
|
updated = models.DateTimeField(auto_now=True, blank=True, null=True, db_index=True)
|
||||||
tags = models.ManyToManyField(Tag, blank=True)
|
|
||||||
|
|
||||||
keys = ('url', 'timestamp', 'title', 'tags', 'updated')
|
keys = ('url', 'timestamp', 'title', 'tags', 'updated')
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue