You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

43 lines
1.9 KiB

# Generated by Django 5.1.8 on 2025-05-06 11:46
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('video', '0006_alter_video_video_type'),
]
operations = [
# First remove the existing collections field
migrations.RemoveField(
model_name='video',
name='collections',
),
# Then create the VideoInCollection model
migrations.CreateModel(
name='VideoInCollection',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('order', models.PositiveIntegerField(default=0, verbose_name='order')),
('created_at', models.DateTimeField(auto_now_add=True, verbose_name='created at')),
('updated_at', models.DateTimeField(auto_now=True, verbose_name='updated at')),
('collection', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='collection_videos', to='video.videocollection', verbose_name='collection')),
('video', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='video_collections', to='video.video', verbose_name='video')),
],
options={
'verbose_name': 'Video in Collection',
'verbose_name_plural': 'Videos in Collections',
'ordering': ['order'],
'unique_together': {('collection', 'video')},
},
),
# Finally add the collections field back with the through model
migrations.AddField(
model_name='video',
name='collections',
field=models.ManyToManyField(blank=True, related_name='related_videos', through='video.VideoInCollection', to='video.videocollection', verbose_name='collections'),
),
]