forked from github/plane
fix: migration file fixes (#3302)
This commit is contained in:
parent
804b7d8663
commit
87cd44bcd2
@ -1,136 +0,0 @@
|
||||
# Generated by Django 4.2.7 on 2023-12-20 11:14
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import plane.db.models.cycle
|
||||
import plane.db.models.issue
|
||||
import plane.db.models.module
|
||||
import plane.db.models.view
|
||||
import plane.db.models.workspace
|
||||
import uuid
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('db', '0050_user_use_case_alter_workspace_organization_size'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='issueview',
|
||||
old_name='query_data',
|
||||
new_name='filters',
|
||||
),
|
||||
migrations.RenameField(
|
||||
model_name='issueproperty',
|
||||
old_name='properties',
|
||||
new_name='display_properties',
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='issueproperty',
|
||||
name='display_properties',
|
||||
field=models.JSONField(default=plane.db.models.issue.get_default_display_properties),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='issueproperty',
|
||||
name='display_filters',
|
||||
field=models.JSONField(default=plane.db.models.issue.get_default_display_filters),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='issueproperty',
|
||||
name='filters',
|
||||
field=models.JSONField(default=plane.db.models.issue.get_default_filters),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='issueview',
|
||||
name='display_filters',
|
||||
field=models.JSONField(default=plane.db.models.view.get_default_display_filters),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='issueview',
|
||||
name='display_properties',
|
||||
field=models.JSONField(default=plane.db.models.view.get_default_display_properties),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='issueview',
|
||||
name='sort_order',
|
||||
field=models.FloatField(default=65535),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='issueview',
|
||||
name='project',
|
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='project_%(class)s', to='db.project'),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='WorkspaceUserProperties',
|
||||
fields=[
|
||||
('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created At')),
|
||||
('updated_at', models.DateTimeField(auto_now=True, verbose_name='Last Modified At')),
|
||||
('id', models.UUIDField(db_index=True, default=uuid.uuid4, editable=False, primary_key=True, serialize=False, unique=True)),
|
||||
('filters', models.JSONField(default=plane.db.models.workspace.get_default_filters)),
|
||||
('display_filters', models.JSONField(default=plane.db.models.workspace.get_default_display_filters)),
|
||||
('display_properties', models.JSONField(default=plane.db.models.workspace.get_default_display_properties)),
|
||||
('created_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_created_by', to=settings.AUTH_USER_MODEL, verbose_name='Created By')),
|
||||
('updated_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_updated_by', to=settings.AUTH_USER_MODEL, verbose_name='Last Modified By')),
|
||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='workspace_user_properties', to=settings.AUTH_USER_MODEL)),
|
||||
('workspace', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='workspace_user_properties', to='db.workspace')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Workspace User Property',
|
||||
'verbose_name_plural': 'Workspace User Property',
|
||||
'db_table': 'Workspace_user_properties',
|
||||
'ordering': ('-created_at',),
|
||||
'unique_together': {('workspace', 'user')},
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='ModuleUserProperties',
|
||||
fields=[
|
||||
('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created At')),
|
||||
('updated_at', models.DateTimeField(auto_now=True, verbose_name='Last Modified At')),
|
||||
('id', models.UUIDField(db_index=True, default=uuid.uuid4, editable=False, primary_key=True, serialize=False, unique=True)),
|
||||
('filters', models.JSONField(default=plane.db.models.module.get_default_filters)),
|
||||
('display_filters', models.JSONField(default=plane.db.models.module.get_default_display_filters)),
|
||||
('display_properties', models.JSONField(default=plane.db.models.module.get_default_display_properties)),
|
||||
('created_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_created_by', to=settings.AUTH_USER_MODEL, verbose_name='Created By')),
|
||||
('module', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='module_user_properties', to='db.module')),
|
||||
('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='project_%(class)s', to='db.project')),
|
||||
('updated_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_updated_by', to=settings.AUTH_USER_MODEL, verbose_name='Last Modified By')),
|
||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='module_user_properties', to=settings.AUTH_USER_MODEL)),
|
||||
('workspace', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='workspace_%(class)s', to='db.workspace')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Module User Property',
|
||||
'verbose_name_plural': 'Module User Property',
|
||||
'db_table': 'module_user_properties',
|
||||
'ordering': ('-created_at',),
|
||||
'unique_together': {('module', 'user')},
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='CycleUserProperties',
|
||||
fields=[
|
||||
('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created At')),
|
||||
('updated_at', models.DateTimeField(auto_now=True, verbose_name='Last Modified At')),
|
||||
('id', models.UUIDField(db_index=True, default=uuid.uuid4, editable=False, primary_key=True, serialize=False, unique=True)),
|
||||
('filters', models.JSONField(default=plane.db.models.cycle.get_default_filters)),
|
||||
('display_filters', models.JSONField(default=plane.db.models.cycle.get_default_display_filters)),
|
||||
('display_properties', models.JSONField(default=plane.db.models.cycle.get_default_display_properties)),
|
||||
('created_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_created_by', to=settings.AUTH_USER_MODEL, verbose_name='Created By')),
|
||||
('cycle', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='cycle_user_properties', to='db.cycle')),
|
||||
('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='project_%(class)s', to='db.project')),
|
||||
('updated_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_updated_by', to=settings.AUTH_USER_MODEL, verbose_name='Last Modified By')),
|
||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='cycle_user_properties', to=settings.AUTH_USER_MODEL)),
|
||||
('workspace', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='workspace_%(class)s', to='db.workspace')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Cycle User Property',
|
||||
'verbose_name_plural': 'Cycle User Properties',
|
||||
'db_table': 'cycle_user_properties',
|
||||
'ordering': ('-created_at',),
|
||||
'unique_together': {('cycle', 'user')},
|
||||
},
|
||||
),
|
||||
]
|
@ -1,65 +1,136 @@
|
||||
# Generated by Django 4.2.7 on 2023-12-19 19:11
|
||||
from plane.db.models import WorkspaceUserProperties, ProjectMember, IssueView
|
||||
from django.db import migrations
|
||||
# Generated by Django 4.2.7 on 2023-12-20 11:14
|
||||
|
||||
|
||||
def workspace_user_properties(apps, schema_editor):
|
||||
WorkspaceMember = apps.get_model("db", "WorkspaceMember")
|
||||
updated_workspace_user_properties = []
|
||||
for workspace_members in WorkspaceMember.objects.all():
|
||||
updated_workspace_user_properties.append(
|
||||
WorkspaceUserProperties(
|
||||
user_id=workspace_members.member_id,
|
||||
display_filters=workspace_members.view_props.get("display_filters"),
|
||||
display_properties=workspace_members.view_props.get("display_properties"),
|
||||
workspace_id=workspace_members.workspace_id,
|
||||
)
|
||||
)
|
||||
WorkspaceUserProperties.objects.bulk_create(updated_workspace_user_properties, batch_size=2000)
|
||||
|
||||
|
||||
def project_user_properties(apps, schema_editor):
|
||||
IssueProperty = apps.get_model("db", "IssueProperty")
|
||||
updated_issue_user_properties = []
|
||||
for issue_property in IssueProperty.objects.all():
|
||||
project_member = ProjectMember.objects.filter(project_id=issue_property.project_id, member_id=issue_property.user_id).first()
|
||||
if project_member:
|
||||
issue_property.filters = project_member.view_props.get("filters")
|
||||
issue_property.display_filters = project_member.view_props.get("display_filters")
|
||||
updated_issue_user_properties.append(issue_property)
|
||||
|
||||
IssueProperty.objects.bulk_update(updated_issue_user_properties, ["filters", "display_filters"], batch_size=2000)
|
||||
|
||||
|
||||
def issue_view(apps, schema_editor):
|
||||
GlobalView = apps.get_model("db", "GlobalView")
|
||||
updated_issue_views = []
|
||||
|
||||
for global_view in GlobalView.objects.all():
|
||||
updated_issue_views.append(
|
||||
IssueView(
|
||||
workspace_id=global_view.workspace_id,
|
||||
name=global_view.name,
|
||||
description=global_view.description,
|
||||
query=global_view.query,
|
||||
access=global_view.access,
|
||||
filters=global_view.query_data.get("filters", {}),
|
||||
sort_order=global_view.sort_order,
|
||||
created_by_id=global_view.created_by_id,
|
||||
updated_by_id=global_view.updated_by_id,
|
||||
)
|
||||
)
|
||||
IssueView.objects.bulk_create(updated_issue_views, batch_size=100)
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import plane.db.models.cycle
|
||||
import plane.db.models.issue
|
||||
import plane.db.models.module
|
||||
import plane.db.models.view
|
||||
import plane.db.models.workspace
|
||||
import uuid
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('db', '0051_remove_issueproperty_properties_and_more'),
|
||||
('db', '0051_cycle_external_id_cycle_external_source_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(workspace_user_properties),
|
||||
migrations.RunPython(project_user_properties),
|
||||
migrations.RunPython(issue_view),
|
||||
migrations.RenameField(
|
||||
model_name='issueview',
|
||||
old_name='query_data',
|
||||
new_name='filters',
|
||||
),
|
||||
migrations.RenameField(
|
||||
model_name='issueproperty',
|
||||
old_name='properties',
|
||||
new_name='display_properties',
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='issueproperty',
|
||||
name='display_properties',
|
||||
field=models.JSONField(default=plane.db.models.issue.get_default_display_properties),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='issueproperty',
|
||||
name='display_filters',
|
||||
field=models.JSONField(default=plane.db.models.issue.get_default_display_filters),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='issueproperty',
|
||||
name='filters',
|
||||
field=models.JSONField(default=plane.db.models.issue.get_default_filters),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='issueview',
|
||||
name='display_filters',
|
||||
field=models.JSONField(default=plane.db.models.view.get_default_display_filters),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='issueview',
|
||||
name='display_properties',
|
||||
field=models.JSONField(default=plane.db.models.view.get_default_display_properties),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='issueview',
|
||||
name='sort_order',
|
||||
field=models.FloatField(default=65535),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='issueview',
|
||||
name='project',
|
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='project_%(class)s', to='db.project'),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='WorkspaceUserProperties',
|
||||
fields=[
|
||||
('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created At')),
|
||||
('updated_at', models.DateTimeField(auto_now=True, verbose_name='Last Modified At')),
|
||||
('id', models.UUIDField(db_index=True, default=uuid.uuid4, editable=False, primary_key=True, serialize=False, unique=True)),
|
||||
('filters', models.JSONField(default=plane.db.models.workspace.get_default_filters)),
|
||||
('display_filters', models.JSONField(default=plane.db.models.workspace.get_default_display_filters)),
|
||||
('display_properties', models.JSONField(default=plane.db.models.workspace.get_default_display_properties)),
|
||||
('created_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_created_by', to=settings.AUTH_USER_MODEL, verbose_name='Created By')),
|
||||
('updated_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_updated_by', to=settings.AUTH_USER_MODEL, verbose_name='Last Modified By')),
|
||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='workspace_user_properties', to=settings.AUTH_USER_MODEL)),
|
||||
('workspace', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='workspace_user_properties', to='db.workspace')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Workspace User Property',
|
||||
'verbose_name_plural': 'Workspace User Property',
|
||||
'db_table': 'Workspace_user_properties',
|
||||
'ordering': ('-created_at',),
|
||||
'unique_together': {('workspace', 'user')},
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='ModuleUserProperties',
|
||||
fields=[
|
||||
('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created At')),
|
||||
('updated_at', models.DateTimeField(auto_now=True, verbose_name='Last Modified At')),
|
||||
('id', models.UUIDField(db_index=True, default=uuid.uuid4, editable=False, primary_key=True, serialize=False, unique=True)),
|
||||
('filters', models.JSONField(default=plane.db.models.module.get_default_filters)),
|
||||
('display_filters', models.JSONField(default=plane.db.models.module.get_default_display_filters)),
|
||||
('display_properties', models.JSONField(default=plane.db.models.module.get_default_display_properties)),
|
||||
('created_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_created_by', to=settings.AUTH_USER_MODEL, verbose_name='Created By')),
|
||||
('module', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='module_user_properties', to='db.module')),
|
||||
('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='project_%(class)s', to='db.project')),
|
||||
('updated_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_updated_by', to=settings.AUTH_USER_MODEL, verbose_name='Last Modified By')),
|
||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='module_user_properties', to=settings.AUTH_USER_MODEL)),
|
||||
('workspace', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='workspace_%(class)s', to='db.workspace')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Module User Property',
|
||||
'verbose_name_plural': 'Module User Property',
|
||||
'db_table': 'module_user_properties',
|
||||
'ordering': ('-created_at',),
|
||||
'unique_together': {('module', 'user')},
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='CycleUserProperties',
|
||||
fields=[
|
||||
('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created At')),
|
||||
('updated_at', models.DateTimeField(auto_now=True, verbose_name='Last Modified At')),
|
||||
('id', models.UUIDField(db_index=True, default=uuid.uuid4, editable=False, primary_key=True, serialize=False, unique=True)),
|
||||
('filters', models.JSONField(default=plane.db.models.cycle.get_default_filters)),
|
||||
('display_filters', models.JSONField(default=plane.db.models.cycle.get_default_display_filters)),
|
||||
('display_properties', models.JSONField(default=plane.db.models.cycle.get_default_display_properties)),
|
||||
('created_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_created_by', to=settings.AUTH_USER_MODEL, verbose_name='Created By')),
|
||||
('cycle', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='cycle_user_properties', to='db.cycle')),
|
||||
('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='project_%(class)s', to='db.project')),
|
||||
('updated_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_updated_by', to=settings.AUTH_USER_MODEL, verbose_name='Last Modified By')),
|
||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='cycle_user_properties', to=settings.AUTH_USER_MODEL)),
|
||||
('workspace', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='workspace_%(class)s', to='db.workspace')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Cycle User Property',
|
||||
'verbose_name_plural': 'Cycle User Properties',
|
||||
'db_table': 'cycle_user_properties',
|
||||
'ordering': ('-created_at',),
|
||||
'unique_together': {('cycle', 'user')},
|
||||
},
|
||||
),
|
||||
]
|
65
apiserver/plane/db/migrations/0053_auto_20240102_1315.py
Normal file
65
apiserver/plane/db/migrations/0053_auto_20240102_1315.py
Normal file
@ -0,0 +1,65 @@
|
||||
# Generated by Django 4.2.7 on 2024-01-02 13:15
|
||||
|
||||
from plane.db.models import WorkspaceUserProperties, ProjectMember, IssueView
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def workspace_user_properties(apps, schema_editor):
|
||||
WorkspaceMember = apps.get_model("db", "WorkspaceMember")
|
||||
updated_workspace_user_properties = []
|
||||
for workspace_members in WorkspaceMember.objects.all():
|
||||
updated_workspace_user_properties.append(
|
||||
WorkspaceUserProperties(
|
||||
user_id=workspace_members.member_id,
|
||||
display_filters=workspace_members.view_props.get("display_filters"),
|
||||
display_properties=workspace_members.view_props.get("display_properties"),
|
||||
workspace_id=workspace_members.workspace_id,
|
||||
)
|
||||
)
|
||||
WorkspaceUserProperties.objects.bulk_create(updated_workspace_user_properties, batch_size=2000)
|
||||
|
||||
|
||||
def project_user_properties(apps, schema_editor):
|
||||
IssueProperty = apps.get_model("db", "IssueProperty")
|
||||
updated_issue_user_properties = []
|
||||
for issue_property in IssueProperty.objects.all():
|
||||
project_member = ProjectMember.objects.filter(project_id=issue_property.project_id, member_id=issue_property.user_id).first()
|
||||
if project_member:
|
||||
issue_property.filters = project_member.view_props.get("filters")
|
||||
issue_property.display_filters = project_member.view_props.get("display_filters")
|
||||
updated_issue_user_properties.append(issue_property)
|
||||
|
||||
IssueProperty.objects.bulk_update(updated_issue_user_properties, ["filters", "display_filters"], batch_size=2000)
|
||||
|
||||
|
||||
def issue_view(apps, schema_editor):
|
||||
GlobalView = apps.get_model("db", "GlobalView")
|
||||
updated_issue_views = []
|
||||
|
||||
for global_view in GlobalView.objects.all():
|
||||
updated_issue_views.append(
|
||||
IssueView(
|
||||
workspace_id=global_view.workspace_id,
|
||||
name=global_view.name,
|
||||
description=global_view.description,
|
||||
query=global_view.query,
|
||||
access=global_view.access,
|
||||
filters=global_view.query_data.get("filters", {}),
|
||||
sort_order=global_view.sort_order,
|
||||
created_by_id=global_view.created_by_id,
|
||||
updated_by_id=global_view.updated_by_id,
|
||||
)
|
||||
)
|
||||
IssueView.objects.bulk_create(updated_issue_views, batch_size=100)
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('db', '0052_auto_20231220_1141'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(workspace_user_properties),
|
||||
migrations.RunPython(project_user_properties),
|
||||
migrations.RunPython(issue_view),
|
||||
]
|
Loading…
Reference in New Issue
Block a user