Data migration for JobAds
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
# Generated by Django 2.2.28 on 2022-07-26 19:29
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def copyOldDataToNewFields(apps, schema_editor):
|
||||
Old = apps.get_model("webapp", "RemoveJobAd")
|
||||
New = apps.get_model("webapp", "JobAd")
|
||||
for jobAd in Old.objects.all():
|
||||
New.objects.create(
|
||||
id=jobAd.id,
|
||||
title=jobAd.title,
|
||||
tags=jobAd.tags,
|
||||
visible=jobAd.visible,
|
||||
deleted=jobAd.deleted,
|
||||
publish_time=jobAd.publish_time,
|
||||
autohide=jobAd.autohide_at,
|
||||
autohide_enabled=jobAd.autohide_enabled,
|
||||
description=jobAd.description,
|
||||
content=jobAd.content,
|
||||
created_at=jobAd.created_at,
|
||||
)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("webapp", "0088_jobad"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(
|
||||
copyOldDataToNewFields, reverse_code=migrations.RunPython.noop
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user