Преглед изворни кода

Enforces files on disk migration with SQLite.

Adrien Panay пре 7 година
родитељ
комит
9748717719
1 измењених фајлова са 18 додато и 5 уклоњено
  1. 18 5
      tracim/migration/versions/69fb10c3d6f0_files_on_disk.py

+ 18 - 5
tracim/migration/versions/69fb10c3d6f0_files_on_disk.py Прегледај датотеку

@@ -1,4 +1,4 @@
1
-"""files on disk
1
+"""files on disk.
2 2
 
3 3
 Revision ID: 69fb10c3d6f0
4 4
 Revises: c1cea4bbae16
@@ -15,11 +15,24 @@ revision = '69fb10c3d6f0'
15 15
 down_revision = 'c1cea4bbae16'
16 16
 
17 17
 
18
+# INFO - A.P - 2017-07-20 - alembic batch migrations
19
+# http://alembic.zzzcomputing.com/en/latest/batch.html
20
+# This migration uses alembic batch mode, a workaround allowing to enforce
21
+# ALTER statement with SQLite while maintaining the traditional behavior of
22
+# the commented lines on other RDBMS.
23
+
24
+
18 25
 def upgrade():
19
-    op.add_column('content_revisions',
20
-                  sa.Column('depot_file',
21
-                            UploadedFileField))
26
+    """Adds the depot file in revision."""
27
+    # op.add_column('content_revisions',
28
+    #               sa.Column('depot_file',
29
+    #                         UploadedFileField))
30
+    with op.batch_alter_table('content_revisions') as batch_op:
31
+        batch_op.add_column(sa.Column('depot_file', UploadedFileField))
22 32
 
23 33
 
24 34
 def downgrade():
25
-    op.drop_column('content_revisions', 'depot_file')
35
+    """Drops the depot file in revision."""
36
+    # op.drop_column('content_revisions', 'depot_file')
37
+    with op.batch_alter_table('content_revisions') as batch_op:
38
+        batch_op.drop_column('depot_file')