Mercurial > libervia-backend
annotate libervia/backend/memory/migration/versions/602caf848068_drop_message_types_table_fix_nullable.py @ 4150:26534d959d2d
Plugin XEP-0384: rename the pun names "OLDMEMO" and "TWOMEMO" to "OMEMO_legacy" and "OMEMO" for clarity.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 22 Nov 2023 14:45:26 +0100 |
parents | 4b842c1fb686 |
children | 0d7bb4df2343 |
rev | line source |
---|---|
3583
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1 """drop message_types table + fix nullable + rename constraints |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
2 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 Revision ID: 602caf848068 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
4 Revises: |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
5 Create Date: 2021-06-26 12:42:54.148313 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
7 """ |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
8 from alembic import op |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
9 from sqlalchemy import ( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
10 Table, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 Column, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
12 MetaData, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
13 TEXT, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
14 INTEGER, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
15 Text, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 Integer, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
17 Float, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
18 Enum, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
19 ForeignKey, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
20 Index, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
21 PrimaryKeyConstraint, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
22 ) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
23 from sqlalchemy.sql import table, column |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
24 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
25 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
26 # revision identifiers, used by Alembic. |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
27 revision = "602caf848068" |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
28 down_revision = None |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
29 branch_labels = None |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
30 depends_on = None |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
31 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
32 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
33 def upgrade(): |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
34 # we have to recreate former tables for batch_alter_table's reflexion, otherwise the |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
35 # database will be used, and this will keep unammed UNIQUE constraints in addition |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
36 # to the named ones that we create |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
37 metadata = MetaData( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
38 naming_convention={ |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
39 "ix": "ix_%(column_0_label)s", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
40 "uq": "uq_%(table_name)s_%(column_0_name)s", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
41 "ck": "ck_%(table_name)s_%(constraint_name)s", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
42 "fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
43 "pk": "pk_%(table_name)s", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
44 }, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
45 ) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
46 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
47 old_profiles_table = Table( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
48 "profiles", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
49 metadata, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
50 Column("id", Integer, primary_key=True, nullable=True, autoincrement=False), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
51 Column("name", Text, unique=True), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
52 ) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
53 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
54 old_components_table = Table( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
55 "components", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
56 metadata, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
57 Column( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
58 "profile_id", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
59 ForeignKey("profiles.id", ondelete="CASCADE"), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
60 nullable=True, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
61 primary_key=True, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
62 ), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
63 Column("entry_point", Text, nullable=False), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
64 ) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
65 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
66 old_message_table = Table( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
67 "message", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
68 metadata, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
69 Column("id", Integer, primary_key=True, nullable=True, autoincrement=False), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
70 Column("history_uid", ForeignKey("history.uid", ondelete="CASCADE")), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
71 Column("message", Text), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
72 Column("language", Text), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
73 Index("message__history_uid", "history_uid"), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
74 ) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
75 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
76 old_subject_table = Table( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
77 "subject", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
78 metadata, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
79 Column("id", Integer, primary_key=True, nullable=True, autoincrement=False), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
80 Column("history_uid", ForeignKey("history.uid", ondelete="CASCADE")), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
81 Column("subject", Text), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
82 Column("language", Text), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
83 Index("subject__history_uid", "history_uid"), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
84 ) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
85 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
86 old_thread_table = Table( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
87 "thread", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
88 metadata, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
89 Column("id", Integer, primary_key=True, nullable=True, autoincrement=False), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
90 Column("history_uid", ForeignKey("history.uid", ondelete="CASCADE")), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
91 Column("thread_id", Text), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
92 Column("parent_id", Text), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
93 Index("thread__history_uid", "history_uid"), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
94 ) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
95 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
96 old_history_table = Table( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
97 "history", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
98 metadata, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
99 Column("uid", Text, primary_key=True, nullable=True), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
100 Column("stanza_id", Text), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
101 Column("update_uid", Text), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
102 Column("profile_id", Integer, ForeignKey("profiles.id", ondelete="CASCADE")), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
103 Column("source", Text), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
104 Column("dest", Text), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
105 Column("source_res", Text), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
106 Column("dest_res", Text), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
107 Column("timestamp", Float, nullable=False), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
108 Column("received_timestamp", Float), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
109 Column("type", Text, ForeignKey("message_types.type")), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
110 Column("extra", Text), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
111 Index("history__profile_id_timestamp", "profile_id", "timestamp"), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
112 Index( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
113 "history__profile_id_received_timestamp", "profile_id", "received_timestamp" |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
114 ), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
115 ) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
116 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
117 old_param_gen_table = Table( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
118 "param_gen", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
119 metadata, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
120 Column("category", Text, primary_key=True), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
121 Column("name", Text, primary_key=True), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
122 Column("value", Text), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
123 ) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
124 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
125 old_param_ind_table = Table( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
126 "param_ind", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
127 metadata, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
128 Column("category", Text, primary_key=True), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
129 Column("name", Text, primary_key=True), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
130 Column( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
131 "profile_id", ForeignKey("profiles.id", ondelete="CASCADE"), primary_key=True |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
132 ), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
133 Column("value", Text), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
134 ) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
135 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
136 old_private_gen_table = Table( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
137 "private_gen", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
138 metadata, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
139 Column("namespace", Text, primary_key=True), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
140 Column("key", Text, primary_key=True), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
141 Column("value", Text), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
142 ) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
143 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
144 old_private_ind_table = Table( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
145 "private_ind", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
146 metadata, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
147 Column("namespace", Text, primary_key=True), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
148 Column("key", Text, primary_key=True), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
149 Column( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
150 "profile_id", ForeignKey("profiles.id", ondelete="CASCADE"), primary_key=True |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
151 ), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
152 Column("value", Text), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
153 ) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
154 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
155 old_private_gen_bin_table = Table( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
156 "private_gen_bin", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
157 metadata, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
158 Column("namespace", Text, primary_key=True), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
159 Column("key", Text, primary_key=True), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
160 Column("value", Text), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
161 ) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
162 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
163 old_private_ind_bin_table = Table( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
164 "private_ind_bin", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
165 metadata, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
166 Column("namespace", Text, primary_key=True), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
167 Column("key", Text, primary_key=True), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
168 Column( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
169 "profile_id", ForeignKey("profiles.id", ondelete="CASCADE"), primary_key=True |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
170 ), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
171 Column("value", Text), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
172 ) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
173 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
174 old_files_table = Table( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
175 "files", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
176 metadata, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
177 Column("id", Text, primary_key=True), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
178 Column("public_id", Text, unique=True), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
179 Column("version", Text, primary_key=True), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
180 Column("parent", Text, nullable=False), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
181 Column( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
182 "type", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
183 Enum("file", "directory", name="file_type", create_constraint=True), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
184 nullable=False, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
185 server_default="file", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
186 ), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
187 Column("file_hash", Text), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
188 Column("hash_algo", Text), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
189 Column("name", Text, nullable=False), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
190 Column("size", Integer), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
191 Column("namespace", Text), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
192 Column("media_type", Text), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
193 Column("media_subtype", Text), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
194 Column("created", Float, nullable=False), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
195 Column("modified", Float), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
196 Column("owner", Text), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
197 Column("access", Text), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
198 Column("extra", Text), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
199 Column("profile_id", ForeignKey("profiles.id", ondelete="CASCADE")), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
200 Index("files__profile_id_owner_parent", "profile_id", "owner", "parent"), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
201 Index( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
202 "files__profile_id_owner_media_type_media_subtype", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
203 "profile_id", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
204 "owner", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
205 "media_type", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
206 "media_subtype", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
207 ), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
208 ) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
209 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
210 op.drop_table("message_types") |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
211 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
212 with op.batch_alter_table( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
213 "profiles", copy_from=old_profiles_table, schema=None |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
214 ) as batch_op: |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
215 batch_op.create_unique_constraint(batch_op.f("uq_profiles_name"), ["name"]) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
216 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
217 with op.batch_alter_table( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
218 "components", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
219 copy_from=old_components_table, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
220 naming_convention={ |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
221 "fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
222 }, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
223 schema=None, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
224 ) as batch_op: |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
225 batch_op.create_unique_constraint(batch_op.f("uq_profiles_name"), ["name"]) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
226 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
227 with op.batch_alter_table( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
228 "history", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
229 copy_from=old_history_table, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
230 naming_convention={ |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
231 "fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
232 }, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
233 schema=None, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
234 ) as batch_op: |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
235 batch_op.alter_column("uid", existing_type=TEXT(), nullable=False) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
236 batch_op.alter_column( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
237 "type", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
238 type_=Enum( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
239 "chat", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
240 "error", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
241 "groupchat", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
242 "headline", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
243 "normal", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
244 "info", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
245 name="message_type", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
246 create_constraint=True, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
247 ), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
248 existing_type=TEXT(), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
249 nullable=False, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
250 ) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
251 batch_op.create_unique_constraint( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
252 batch_op.f("uq_history_profile_id"), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
253 ["profile_id", "stanza_id", "source", "dest"], |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
254 ) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
255 batch_op.drop_constraint("fk_history_type_message_types", type_="foreignkey") |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
256 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
257 with op.batch_alter_table( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
258 "message", copy_from=old_message_table, schema=None |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
259 ) as batch_op: |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
260 batch_op.alter_column( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
261 "id", existing_type=INTEGER(), nullable=False, autoincrement=False |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
262 ) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
263 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
264 with op.batch_alter_table( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
265 "subject", copy_from=old_subject_table, schema=None |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
266 ) as batch_op: |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
267 batch_op.alter_column( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
268 "id", existing_type=INTEGER(), nullable=False, autoincrement=False |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
269 ) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
270 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
271 with op.batch_alter_table( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
272 "thread", copy_from=old_thread_table, schema=None |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
273 ) as batch_op: |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
274 batch_op.alter_column( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
275 "id", existing_type=INTEGER(), nullable=False, autoincrement=False |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
276 ) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
277 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
278 with op.batch_alter_table( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
279 "param_gen", copy_from=old_param_gen_table, schema=None |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
280 ) as batch_op: |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
281 batch_op.alter_column("category", existing_type=TEXT(), nullable=False) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
282 batch_op.alter_column("name", existing_type=TEXT(), nullable=False) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
283 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
284 with op.batch_alter_table( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
285 "param_ind", copy_from=old_param_ind_table, schema=None |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
286 ) as batch_op: |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
287 batch_op.alter_column("category", existing_type=TEXT(), nullable=False) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
288 batch_op.alter_column("name", existing_type=TEXT(), nullable=False) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
289 batch_op.alter_column("profile_id", existing_type=INTEGER(), nullable=False) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
290 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
291 with op.batch_alter_table( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
292 "private_gen", copy_from=old_private_gen_table, schema=None |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
293 ) as batch_op: |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
294 batch_op.alter_column("namespace", existing_type=TEXT(), nullable=False) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
295 batch_op.alter_column("key", existing_type=TEXT(), nullable=False) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
296 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
297 with op.batch_alter_table( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
298 "private_ind", copy_from=old_private_ind_table, schema=None |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
299 ) as batch_op: |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
300 batch_op.alter_column("namespace", existing_type=TEXT(), nullable=False) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
301 batch_op.alter_column("key", existing_type=TEXT(), nullable=False) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
302 batch_op.alter_column("profile_id", existing_type=INTEGER(), nullable=False) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
303 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
304 with op.batch_alter_table( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
305 "private_gen_bin", copy_from=old_private_gen_bin_table, schema=None |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
306 ) as batch_op: |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
307 batch_op.alter_column("namespace", existing_type=TEXT(), nullable=False) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
308 batch_op.alter_column("key", existing_type=TEXT(), nullable=False) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
309 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
310 # found some invalid rows in local database, maybe old values made during development, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
311 # but in doubt we have to delete them |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
312 op.execute("DELETE FROM private_ind_bin WHERE namespace IS NULL") |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
313 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
314 with op.batch_alter_table( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
315 "private_ind_bin", copy_from=old_private_ind_bin_table, schema=None |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
316 ) as batch_op: |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
317 batch_op.alter_column("namespace", existing_type=TEXT(), nullable=False) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
318 batch_op.alter_column("key", existing_type=TEXT(), nullable=False) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
319 batch_op.alter_column("profile_id", existing_type=INTEGER(), nullable=False) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
320 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
321 with op.batch_alter_table( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
322 "files", copy_from=old_files_table, schema=None |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
323 ) as batch_op: |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
324 batch_op.create_unique_constraint(batch_op.f("uq_files_public_id"), ["public_id"]) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
325 batch_op.alter_column( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
326 "type", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
327 type_=Enum("file", "directory", name="file_type", create_constraint=True), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
328 existing_type=Text(), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
329 nullable=False, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
330 ) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
331 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
332 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
333 def downgrade(): |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
334 # downgrade doesn't restore the exact same state as before upgrade, as it |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
335 # would be useless and waste of resource to restore broken things such as |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
336 # anonymous constraints |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
337 with op.batch_alter_table("thread", schema=None) as batch_op: |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
338 batch_op.alter_column( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
339 "id", existing_type=INTEGER(), nullable=True, autoincrement=False |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
340 ) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
341 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
342 with op.batch_alter_table("subject", schema=None) as batch_op: |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
343 batch_op.alter_column( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
344 "id", existing_type=INTEGER(), nullable=True, autoincrement=False |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
345 ) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
346 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
347 with op.batch_alter_table("private_ind_bin", schema=None) as batch_op: |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
348 batch_op.alter_column("profile_id", existing_type=INTEGER(), nullable=True) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
349 batch_op.alter_column("key", existing_type=TEXT(), nullable=True) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
350 batch_op.alter_column("namespace", existing_type=TEXT(), nullable=True) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
351 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
352 with op.batch_alter_table("private_ind", schema=None) as batch_op: |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
353 batch_op.alter_column("profile_id", existing_type=INTEGER(), nullable=True) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
354 batch_op.alter_column("key", existing_type=TEXT(), nullable=True) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
355 batch_op.alter_column("namespace", existing_type=TEXT(), nullable=True) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
356 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
357 with op.batch_alter_table("private_gen_bin", schema=None) as batch_op: |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
358 batch_op.alter_column("key", existing_type=TEXT(), nullable=True) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
359 batch_op.alter_column("namespace", existing_type=TEXT(), nullable=True) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
360 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
361 with op.batch_alter_table("private_gen", schema=None) as batch_op: |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
362 batch_op.alter_column("key", existing_type=TEXT(), nullable=True) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
363 batch_op.alter_column("namespace", existing_type=TEXT(), nullable=True) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
364 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
365 with op.batch_alter_table("param_ind", schema=None) as batch_op: |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
366 batch_op.alter_column("profile_id", existing_type=INTEGER(), nullable=True) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
367 batch_op.alter_column("name", existing_type=TEXT(), nullable=True) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
368 batch_op.alter_column("category", existing_type=TEXT(), nullable=True) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
369 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
370 with op.batch_alter_table("param_gen", schema=None) as batch_op: |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
371 batch_op.alter_column("name", existing_type=TEXT(), nullable=True) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
372 batch_op.alter_column("category", existing_type=TEXT(), nullable=True) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
373 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
374 with op.batch_alter_table("message", schema=None) as batch_op: |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
375 batch_op.alter_column( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
376 "id", existing_type=INTEGER(), nullable=True, autoincrement=False |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
377 ) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
378 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
379 op.create_table( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
380 "message_types", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
381 Column("type", TEXT(), nullable=True), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
382 PrimaryKeyConstraint("type"), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
383 ) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
384 message_types_table = table("message_types", column("type", TEXT())) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
385 op.bulk_insert( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
386 message_types_table, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
387 [ |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
388 {"type": "chat"}, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
389 {"type": "error"}, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
390 {"type": "groupchat"}, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
391 {"type": "headline"}, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
392 {"type": "normal"}, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
393 {"type": "info"}, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
394 ], |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
395 ) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
396 |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
397 with op.batch_alter_table("history", schema=None) as batch_op: |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
398 batch_op.alter_column( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
399 "type", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
400 type_=TEXT(), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
401 existing_type=TEXT(), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
402 nullable=True, |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
403 ) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
404 batch_op.create_foreign_key( |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
405 batch_op.f("fk_history_type_message_types"), |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
406 "message_types", |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
407 ["type"], |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
408 ["type"], |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
409 ) |
16ade4ad63f3
core (memory/sqla_mapping): fix some technical debt:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
410 batch_op.alter_column("uid", existing_type=TEXT(), nullable=True) |