Migrations: Squash migrations

Squash together the following migrations:

  - Common: 0010 to 0011
  - Documents: 0029 to 0037
  - Documents: 0042 to 0043
  - Tags: 0001 to 0008

Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
This commit is contained in:
Roberto Rosario
2018-12-08 03:02:04 -04:00
parent aaea84b386
commit fad2ae3683
12 changed files with 418 additions and 8 deletions
@@ -0,0 +1,144 @@
from __future__ import unicode_literals
import uuid
from django.db import connection, migrations, models
import django.db.models.deletion
def operation_convert_uuid_to_hex(apps, schema_editor):
Document = apps.get_model('documents', 'Document')
for document in Document.objects.using(schema_editor.connection.alias).all():
document.uuid = uuid.UUID(document.uuid).hex
document.save()
def operation_convert_uuid_model_field_to_native_minus_oracle(apps, schema_editor):
if not schema_editor.connection.vendor == 'oracle':
# Skip this migration for Oracle
# GitHub issue #251
migrations.AlterField(
field=models.UUIDField(default=uuid.uuid4, editable=False),
model_name='document', name='uuid',
)
def operation_convert_uuid_db_field_to_native_postgresql(apps, schema_editor):
if connection.vendor == 'postgresql':
migrations.RunSQL(
'ALTER TABLE documents_document ALTER COLUMN uuid SET '
'DATA TYPE UUID USING uuid::uuid;'
)
class Migration(migrations.Migration):
replaces = [
('documents', '0029_auto_20160122_0755'),
('documents', '0030_auto_20160309_1837'),
('documents', '0031_convert_uuid'),
('documents', '0032_auto_20160315_0537'),
('documents', '0033_auto_20160325_0052'),
('documents', '0034_auto_20160509_2321'),
('documents', '0035_auto_20161102_0633'),
('documents', '0036_auto_20161222_0534'),
('documents', '0037_auto_20161231_0617')
]
dependencies = [
('documents', '0028_newversionblock'),
]
operations = [
migrations.AlterField(
field=models.CharField(
blank=True, default='eng', max_length=8,
verbose_name='Language'
), model_name='document', name='language',
),
migrations.AlterField(
field=models.PositiveIntegerField(
blank=True, default=30, help_text='Amount of time after '
'which documents of this type in the trash will be '
'deleted.', null=True, verbose_name='Delete time period'
), model_name='documenttype', name='delete_time_period',
),
migrations.AlterField(
field=models.CharField(
blank=True, choices=[
('days', 'Days'), ('hours', 'Hours'),
('minutes', 'Minutes')
], default='days', max_length=8, null=True,
verbose_name='Delete time unit'
), model_name='documenttype', name='delete_time_unit',
),
migrations.RunPython(
code=operation_convert_uuid_to_hex,
),
migrations.RunPython(
code=operation_convert_uuid_model_field_to_native_minus_oracle,
),
migrations.RunPython(
code=operation_convert_uuid_db_field_to_native_postgresql,
),
migrations.AlterModelOptions(
name='documenttypefilename', options={
'ordering': ('filename',), 'verbose_name': 'Quick label',
'verbose_name_plural': 'Quick labels'
},
),
migrations.AlterField(
field=models.BooleanField(
db_index=True, default=False, editable=False,
verbose_name='In trash?'
), model_name='document', name='in_trash',
),
migrations.AlterField(
field=models.BooleanField(
db_index=True, default=True, editable=False, help_text='A '
'document stub is a document with an entry on the database '
'but no file uploaded. This could be an interrupted upload '
'or a deferred upload via the API.', verbose_name='Is stub?'
), model_name='document', name='is_stub',
),
migrations.CreateModel(
fields=[
(
'id', models.AutoField(
auto_created=True, primary_key=True, serialize=False,
verbose_name='ID'
)
),
(
'filename', models.CharField(
max_length=128, verbose_name='Filename'
)
),
], name='DocumentPageCachedImage', options={
'verbose_name': 'Document page cached image',
'verbose_name_plural': 'Document page cached images',
},
),
migrations.CreateModel(
bases=('documents.documentpage',), fields=[],
name='DocumentPageResult', options={
'ordering': ('document_version__document', 'page_number'),
'proxy': True, 'verbose_name': 'Document page',
'verbose_name_plural': 'Document pages',
},
),
migrations.AddField(
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name='cached_images', to='documents.DocumentPage',
verbose_name='Document page'
), model_name='documentpagecachedimage', name='document_page',
),
migrations.RemoveField(
model_name='newversionblock', name='document',
),
migrations.DeleteModel(
name='NewVersionBlock',
),
]
@@ -0,0 +1,48 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2018-12-08 06:35
from __future__ import unicode_literals
import django.core.files.storage
from django.db import migrations, models
import mayan.apps.documents.utils
class Migration(migrations.Migration):
replaces = [
('documents', '0042_auto_20180403_0702'),
('documents', '0043_auto_20180429_0759')
]
dependencies = [
('documents', '0041_auto_20170823_1855'),
]
operations = [
migrations.AlterField(
field=models.FileField(
storage=django.core.files.storage.FileSystemStorage(
location=b'mayan/media/document_storage'
), upload_to=mayan.apps.documents.utils.document_uuid_function,
verbose_name='File'
), model_name='documentversion', name='file',
),
migrations.AlterField(
model_name='documentversion',
name='encoding',
field=models.CharField(blank=True, editable=False, max_length=64, null=True, verbose_name='Encoding'),
),
migrations.AlterField(
field=models.FileField(
storage=django.core.files.storage.FileSystemStorage(
location=b'/home/rosarior/development/mayan-edms/mayan/media/document_storage'
), upload_to=mayan.apps.documents.utils.document_uuid_function,
verbose_name='File'
), model_name='documentversion', name='file',
),
migrations.AlterField(
model_name='documentversion',
name='mimetype',
field=models.CharField(blank=True, editable=False, max_length=255, null=True, verbose_name='MIME type'),
),
]