修复迁移文件

pull/8873/head
feng626 2 years ago
parent 951d4e4e0d
commit 28541c48f7

@ -1,23 +0,0 @@
# Generated by Django 3.2.12 on 2022-07-14 02:46
from django.db import migrations
def migrate_db_oracle_version_to_attrs(apps, schema_editor):
db_alias = schema_editor.connection.alias
model = apps.get_model("applications", "Application")
oracles = list(model.objects.using(db_alias).filter(type='oracle'))
for o in oracles:
o.attrs['version'] = '12c'
model.objects.using(db_alias).bulk_update(oracles, ['attrs'])
class Migration(migrations.Migration):
dependencies = [
('applications', '0021_auto_20220629_1826'),
]
operations = [
migrations.RunPython(migrate_db_oracle_version_to_attrs)
]

@ -3,13 +3,22 @@
from django.db import migrations
class Migration(migrations.Migration):
def migrate_db_oracle_version_to_attrs(apps, schema_editor):
db_alias = schema_editor.connection.alias
model = apps.get_model("applications", "Application")
oracles = list(model.objects.using(db_alias).filter(type='oracle'))
for o in oracles:
o.attrs['version'] = '12c'
model.objects.using(db_alias).bulk_update(oracles, ['attrs'])
class Migration(migrations.Migration):
dependencies = [
('applications', '0021_auto_20220629_1826'),
]
operations = [
migrations.RunPython(migrate_db_oracle_version_to_attrs),
migrations.AlterUniqueTogether(
name='account',
unique_together=None,

@ -1,48 +0,0 @@
# Generated by Django 3.1.14 on 2022-07-15 07:56
import time
from collections import defaultdict
from django.db import migrations
def migrate_account_dirty_data(apps, schema_editor):
db_alias = schema_editor.connection.alias
account_model = apps.get_model('applications', 'Account')
count = 0
bulk_size = 1000
while True:
accounts = account_model.objects.using(db_alias) \
.filter(org_id='')[count:count + bulk_size]
if not accounts:
break
accounts = list(accounts)
start = time.time()
for i in accounts:
if i.app:
org_id = i.app.org_id
elif i.systemuser:
org_id = i.systemuser.org_id
else:
org_id = ''
if org_id:
i.org_id = org_id
account_model.objects.bulk_update(accounts, ['org_id', ])
print("Update account org is empty: {}-{} using: {:.2f}s".format(
count, count + len(accounts), time.time() - start
))
count += len(accounts)
class Migration(migrations.Migration):
dependencies = [
('applications', '0022_auto_20220714_1046'),
]
operations = [
migrations.RunPython(migrate_account_dirty_data),
]

@ -1,10 +1,43 @@
# Generated by Django 3.2.14 on 2022-08-17 09:16
import time
from django.db import migrations
class Migration(migrations.Migration):
def migrate_account_dirty_data(apps, schema_editor):
db_alias = schema_editor.connection.alias
account_model = apps.get_model('applications', 'Account')
count = 0
bulk_size = 1000
while True:
accounts = account_model.objects.using(db_alias) \
.filter(org_id='')[count:count + bulk_size]
if not accounts:
break
accounts = list(accounts)
start = time.time()
for i in accounts:
if i.app:
org_id = i.app.org_id
elif i.systemuser:
org_id = i.systemuser.org_id
else:
org_id = ''
if org_id:
i.org_id = org_id
account_model.objects.bulk_update(accounts, ['org_id', ])
print("Update account org is empty: {}-{} using: {:.2f}s".format(
count, count + len(accounts), time.time() - start
))
count += len(accounts)
class Migration(migrations.Migration):
dependencies = [
('applications', '0022_auto_20220817_1346'),
('perms', '0031_auto_20220816_1600'),
@ -14,6 +47,7 @@ class Migration(migrations.Migration):
]
operations = [
migrations.RunPython(migrate_account_dirty_data),
migrations.DeleteModel(
name='Account',
),

@ -14,4 +14,7 @@ class Migration(migrations.Migration):
name='organization',
options={'permissions': (('view_rootorg', 'Can view root org'), ('view_alljoinedorg', 'Can view all joined org')), 'verbose_name': 'Organization'},
),
migrations.DeleteModel(
name='OrganizationMember',
),
]

@ -1,16 +0,0 @@
# Generated by Django 3.2.14 on 2022-08-11 07:11
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('orgs', '0012_auto_20220118_1054'),
]
operations = [
migrations.DeleteModel(
name='OrganizationMember',
),
]

@ -1,4 +1,4 @@
# Generated by Django 3.2.12 on 2022-07-13 06:17
# Generated by Django 3.1.14 on 2022-04-07 09:26
import common.db.fields
import django.core.validators
@ -6,7 +6,6 @@ from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('terminal', '0051_sessionsharing_users'),
]
@ -15,11 +14,15 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='endpoint',
name='oracle_11g_port',
field=common.db.fields.PortField(default=15211, validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(65535)], verbose_name='Oracle 11g Port'),
field=common.db.fields.PortField(default=15211, validators=[
django.core.validators.MinValueValidator(0),
django.core.validators.MaxValueValidator(65535)], verbose_name='Oracle 11g Port'),
),
migrations.AddField(
model_name='endpoint',
name='oracle_12c_port',
field=common.db.fields.PortField(default=15212, validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(65535)], verbose_name='Oracle 12c Port'),
field=common.db.fields.PortField(default=15212, validators=[
django.core.validators.MinValueValidator(0),
django.core.validators.MaxValueValidator(65535)], verbose_name='Oracle 12c Port'),
),
]

@ -1,4 +1,4 @@
# Generated by Django 3.1.14 on 2022-04-07 09:26
# Generated by Django 3.2.13 on 2022-08-30 04:44
from django.db import migrations, models
@ -6,7 +6,7 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('terminal', '0051_sessionsharing_users'),
('terminal', '0052_auto_20220713_1417'),
]
operations = [

@ -1,10 +1,9 @@
# Generated by Django 3.1.14 on 2022-07-22 08:03
# Generated by Django 3.2.14 on 2022-07-28 03:25
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('tickets', '0017_auto_20220623_1027'),
]
@ -13,6 +12,11 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='applyapplicationticket',
name='apply_actions',
field=models.IntegerField(choices=[(255, 'All'), (1, 'Connect'), (2, 'Upload file'), (4, 'Download file'), (6, 'Upload download'), (8, 'Clipboard copy'), (16, 'Clipboard paste'), (24, 'Clipboard copy paste')], default=255, verbose_name='Actions'),
field=models.IntegerField(
choices=[
(255, 'All'), (1, 'Connect'), (2, 'Upload file'), (4, 'Download file'), (6, 'Upload download'),
(8, 'Clipboard copy'), (16, 'Clipboard paste'), (24, 'Clipboard copy paste')
], default=255,
verbose_name='Actions'),
),
]

@ -1,23 +0,0 @@
# Generated by Django 3.2.14 on 2022-07-28 03:25
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('tickets', '0017_auto_20220623_1027'),
]
operations = [
migrations.AlterField(
model_name='applyapplicationticket',
name='apply_permission_name',
field=models.CharField(max_length=128, verbose_name='Permission name'),
),
migrations.AlterField(
model_name='applyassetticket',
name='apply_permission_name',
field=models.CharField(max_length=128, verbose_name='Permission name'),
),
]

@ -6,7 +6,7 @@ from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('tickets', '0018_auto_20220728_1125'),
('tickets', '0018_applyapplicationticket_apply_actions'),
]
operations = [

@ -50,6 +50,16 @@ class Migration(migrations.Migration):
]
operations = [
migrations.AlterField(
model_name='applyapplicationticket',
name='apply_permission_name',
field=models.CharField(max_length=128, verbose_name='Permission name'),
),
migrations.AlterField(
model_name='applyassetticket',
name='apply_permission_name',
field=models.CharField(max_length=128, verbose_name='Permission name'),
),
migrations.AddField(
model_name='applyassetticket',
name='apply_accounts',

@ -0,0 +1,18 @@
# Generated by Django 3.2.13 on 2022-08-30 03:24
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('users', '0039_auto_20211229_1852'),
]
operations = [
migrations.AlterField(
model_name='user',
name='source',
field=models.CharField(choices=[('local', 'Local'), ('ldap', 'LDAP/AD'), ('openid', 'OpenID'), ('radius', 'Radius'), ('cas', 'CAS'), ('saml2', 'SAML2'), ('oauth2', 'OAuth2')], default='local', max_length=30, verbose_name='Source'),
),
]
Loading…
Cancel
Save