slidge 0.3.0a3__py3-none-any.whl → 0.3.0b2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- slidge/contact/contact.py +2 -2
- slidge/contact/roster.py +2 -0
- slidge/core/dispatcher/message/message.py +3 -1
- slidge/core/dispatcher/presence.py +5 -0
- slidge/core/gateway.py +1 -1
- slidge/core/mixins/attachment.py +31 -0
- slidge/core/mixins/avatar.py +8 -13
- slidge/core/session.py +7 -3
- slidge/db/alembic/versions/cef02a8b1451_initial_schema.py +361 -0
- slidge/group/participant.py +1 -1
- slidge/group/room.py +52 -53
- slidge/main.py +6 -4
- slidge/migration.py +14 -5
- slidge/util/conf.py +4 -1
- {slidge-0.3.0a3.dist-info → slidge-0.3.0b2.dist-info}/METADATA +1 -1
- {slidge-0.3.0a3.dist-info → slidge-0.3.0b2.dist-info}/RECORD +20 -43
- slidge/db/alembic/versions/0337c90c0b96_unify_legacy_xmpp_id_mappings.py +0 -183
- slidge/db/alembic/versions/04cf35e3cf85_add_participant_nickname_no_illegal.py +0 -33
- slidge/db/alembic/versions/09f27f098baa_add_missing_attributes_in_room.py +0 -36
- slidge/db/alembic/versions/15b0bd83407a_remove_bogus_unique_constraints_on_room_.py +0 -85
- slidge/db/alembic/versions/2461390c0af2_store_contacts_caps_verstring_in_db.py +0 -36
- slidge/db/alembic/versions/29f5280c61aa_store_subject_setter_in_room.py +0 -37
- slidge/db/alembic/versions/2b1f45ab7379_store_room_subject_setter_by_nickname.py +0 -41
- slidge/db/alembic/versions/3071e0fa69d4_add_contact_client_type.py +0 -52
- slidge/db/alembic/versions/3231d2c623bc_add_unique_contraint_for_attachment_.py +0 -33
- slidge/db/alembic/versions/45c24cc73c91_add_bob.py +0 -42
- slidge/db/alembic/versions/4dbd23a3f868_new_avatar_store.py +0 -105
- slidge/db/alembic/versions/54ce3cde350c_use_hash_for_avatar_filenames.py +0 -50
- slidge/db/alembic/versions/58b98dacf819_refactor.py +0 -118
- slidge/db/alembic/versions/5bd48bfdffa2_lift_room_legacy_id_constraint.py +0 -61
- slidge/db/alembic/versions/75a62b74b239_ditch_hats_table.py +0 -74
- slidge/db/alembic/versions/82a4af84b679_add_muc_history_filled.py +0 -48
- slidge/db/alembic/versions/8b993243a536_add_vcard_content_to_contact_table.py +0 -43
- slidge/db/alembic/versions/8d2ced764698_rely_on_db_to_store_contacts_rooms_and_.py +0 -139
- slidge/db/alembic/versions/aa9d82a7f6ef_db_creation.py +0 -50
- slidge/db/alembic/versions/abba1ae0edb3_store_avatar_legacy_id_in_the_contact_.py +0 -79
- slidge/db/alembic/versions/b33993e87db3_move_everything_to_persistent_db.py +0 -214
- slidge/db/alembic/versions/b64b1a793483_add_source_and_legacy_id_for_archived_.py +0 -52
- slidge/db/alembic/versions/c4a8ec35a0e8_per_room_user_nick.py +0 -34
- slidge/db/alembic/versions/e91195719c2c_store_users_avatars_persistently.py +0 -26
- {slidge-0.3.0a3.dist-info → slidge-0.3.0b2.dist-info}/WHEEL +0 -0
- {slidge-0.3.0a3.dist-info → slidge-0.3.0b2.dist-info}/entry_points.txt +0 -0
- {slidge-0.3.0a3.dist-info → slidge-0.3.0b2.dist-info}/licenses/LICENSE +0 -0
- {slidge-0.3.0a3.dist-info → slidge-0.3.0b2.dist-info}/top_level.txt +0 -0
@@ -1,74 +0,0 @@
|
|
1
|
-
"""Ditch hats table
|
2
|
-
|
3
|
-
Revision ID: 75a62b74b239
|
4
|
-
Revises: 0337c90c0b96
|
5
|
-
Create Date: 2025-05-02 14:24:26.141034
|
6
|
-
|
7
|
-
"""
|
8
|
-
|
9
|
-
from typing import Sequence, Union
|
10
|
-
|
11
|
-
import sqlalchemy as sa
|
12
|
-
from alembic import op
|
13
|
-
|
14
|
-
# revision identifiers, used by Alembic.
|
15
|
-
revision: str = "75a62b74b239"
|
16
|
-
down_revision: Union[str, None] = "0337c90c0b96"
|
17
|
-
branch_labels: Union[str, Sequence[str], None] = None
|
18
|
-
depends_on: Union[str, Sequence[str], None] = None
|
19
|
-
|
20
|
-
|
21
|
-
def upgrade() -> None:
|
22
|
-
# ### commands auto generated by Alembic - please adjust! ###
|
23
|
-
op.drop_table("participant_hats")
|
24
|
-
op.drop_table("hat")
|
25
|
-
with op.batch_alter_table("contact", schema=None) as batch_op:
|
26
|
-
batch_op.drop_constraint("uq_contact_user_account_id", type_="unique")
|
27
|
-
batch_op.create_unique_constraint(
|
28
|
-
batch_op.f("uq_contact_user_account_id"), ["user_account_id", "jid"]
|
29
|
-
)
|
30
|
-
|
31
|
-
with op.batch_alter_table("participant", schema=None) as batch_op:
|
32
|
-
batch_op.add_column(
|
33
|
-
sa.Column("hats", sa.JSON(), nullable=False, server_default="[]")
|
34
|
-
)
|
35
|
-
|
36
|
-
# ### end Alembic commands ###
|
37
|
-
|
38
|
-
|
39
|
-
def downgrade() -> None:
|
40
|
-
# ### commands auto generated by Alembic - please adjust! ###
|
41
|
-
with op.batch_alter_table("participant", schema=None) as batch_op:
|
42
|
-
batch_op.drop_column("hats")
|
43
|
-
|
44
|
-
with op.batch_alter_table("contact", schema=None) as batch_op:
|
45
|
-
batch_op.drop_constraint(
|
46
|
-
batch_op.f("uq_contact_user_account_id"), type_="unique"
|
47
|
-
)
|
48
|
-
batch_op.create_unique_constraint(
|
49
|
-
"uq_contact_user_account_id", ["user_account_id", "legacy_id"]
|
50
|
-
)
|
51
|
-
|
52
|
-
op.create_table(
|
53
|
-
"hat",
|
54
|
-
sa.Column("id", sa.INTEGER(), nullable=False),
|
55
|
-
sa.Column("title", sa.VARCHAR(), nullable=False),
|
56
|
-
sa.Column("uri", sa.VARCHAR(), nullable=False),
|
57
|
-
sa.PrimaryKeyConstraint("id"),
|
58
|
-
sa.UniqueConstraint("title", "uri", name="uq_hat_title"),
|
59
|
-
)
|
60
|
-
op.create_table(
|
61
|
-
"participant_hats",
|
62
|
-
sa.Column("participant_id", sa.INTEGER(), nullable=False),
|
63
|
-
sa.Column("hat_id", sa.INTEGER(), nullable=False),
|
64
|
-
sa.ForeignKeyConstraint(
|
65
|
-
["hat_id"],
|
66
|
-
["hat.id"],
|
67
|
-
),
|
68
|
-
sa.ForeignKeyConstraint(
|
69
|
-
["participant_id"],
|
70
|
-
["participant.id"],
|
71
|
-
),
|
72
|
-
sa.PrimaryKeyConstraint("participant_id", "hat_id"),
|
73
|
-
)
|
74
|
-
# ### end Alembic commands ###
|
@@ -1,48 +0,0 @@
|
|
1
|
-
"""Add MUC.history_filled
|
2
|
-
|
3
|
-
Also drop caps_ver_bare column that should never have been added.
|
4
|
-
|
5
|
-
Revision ID: 82a4af84b679
|
6
|
-
Revises: 2461390c0af2
|
7
|
-
Create Date: 2024-07-22 07:01:05.352737
|
8
|
-
|
9
|
-
"""
|
10
|
-
|
11
|
-
from typing import Sequence, Union
|
12
|
-
|
13
|
-
import sqlalchemy as sa
|
14
|
-
from alembic import op
|
15
|
-
|
16
|
-
# revision identifiers, used by Alembic.
|
17
|
-
revision: str = "82a4af84b679"
|
18
|
-
down_revision: Union[str, None] = "2461390c0af2"
|
19
|
-
branch_labels: Union[str, Sequence[str], None] = None
|
20
|
-
depends_on: Union[str, Sequence[str], None] = None
|
21
|
-
|
22
|
-
|
23
|
-
def upgrade() -> None:
|
24
|
-
# ### commands auto generated by Alembic - please adjust! ###
|
25
|
-
with op.batch_alter_table("contact", schema=None) as batch_op:
|
26
|
-
batch_op.drop_column("caps_ver_bare")
|
27
|
-
|
28
|
-
with op.batch_alter_table("room", schema=None) as batch_op:
|
29
|
-
batch_op.add_column(
|
30
|
-
sa.Column(
|
31
|
-
"history_filled",
|
32
|
-
sa.Boolean(),
|
33
|
-
nullable=False,
|
34
|
-
server_default=sa.False_(), # manually added
|
35
|
-
)
|
36
|
-
)
|
37
|
-
# ### end Alembic commands ###
|
38
|
-
|
39
|
-
|
40
|
-
def downgrade() -> None:
|
41
|
-
# ### commands auto generated by Alembic - please adjust! ###
|
42
|
-
with op.batch_alter_table("room", schema=None) as batch_op:
|
43
|
-
batch_op.drop_column("history_filled")
|
44
|
-
|
45
|
-
with op.batch_alter_table("contact", schema=None) as batch_op:
|
46
|
-
batch_op.add_column(sa.Column("caps_ver_bare", sa.VARCHAR(), nullable=True))
|
47
|
-
|
48
|
-
# ### end Alembic commands ###
|
@@ -1,43 +0,0 @@
|
|
1
|
-
"""Add vcard content to contact table
|
2
|
-
|
3
|
-
Revision ID: 8b993243a536
|
4
|
-
Revises: 5bd48bfdffa2
|
5
|
-
Create Date: 2024-07-24 07:02:47.770894
|
6
|
-
|
7
|
-
"""
|
8
|
-
|
9
|
-
from typing import Sequence, Union
|
10
|
-
|
11
|
-
import sqlalchemy as sa
|
12
|
-
from alembic import op
|
13
|
-
|
14
|
-
# revision identifiers, used by Alembic.
|
15
|
-
revision: str = "8b993243a536"
|
16
|
-
down_revision: Union[str, None] = "5bd48bfdffa2"
|
17
|
-
branch_labels: Union[str, Sequence[str], None] = None
|
18
|
-
depends_on: Union[str, Sequence[str], None] = None
|
19
|
-
|
20
|
-
|
21
|
-
def upgrade() -> None:
|
22
|
-
# ### commands auto generated by Alembic - please adjust! ###
|
23
|
-
with op.batch_alter_table("contact", schema=None) as batch_op:
|
24
|
-
batch_op.add_column(sa.Column("vcard", sa.String(), nullable=True))
|
25
|
-
batch_op.add_column(
|
26
|
-
sa.Column(
|
27
|
-
"vcard_fetched",
|
28
|
-
sa.Boolean(),
|
29
|
-
nullable=False,
|
30
|
-
server_default=sa.sql.true(),
|
31
|
-
)
|
32
|
-
)
|
33
|
-
|
34
|
-
# ### end Alembic commands ###
|
35
|
-
|
36
|
-
|
37
|
-
def downgrade() -> None:
|
38
|
-
# ### commands auto generated by Alembic - please adjust! ###
|
39
|
-
with op.batch_alter_table("contact", schema=None) as batch_op:
|
40
|
-
batch_op.drop_column("vcard_fetched")
|
41
|
-
batch_op.drop_column("vcard")
|
42
|
-
|
43
|
-
# ### end Alembic commands ###
|
@@ -1,139 +0,0 @@
|
|
1
|
-
"""Rely on DB to store contacts, rooms and participants
|
2
|
-
|
3
|
-
Revision ID: 8d2ced764698
|
4
|
-
Revises: b33993e87db3
|
5
|
-
Create Date: 2024-07-08 14:39:47.022088
|
6
|
-
|
7
|
-
"""
|
8
|
-
|
9
|
-
from typing import Sequence, Union
|
10
|
-
|
11
|
-
import sqlalchemy as sa
|
12
|
-
from alembic import op
|
13
|
-
|
14
|
-
import slidge.db.meta
|
15
|
-
|
16
|
-
# revision identifiers, used by Alembic.
|
17
|
-
revision: str = "8d2ced764698"
|
18
|
-
down_revision: Union[str, None] = "b33993e87db3"
|
19
|
-
branch_labels: Union[str, Sequence[str], None] = None
|
20
|
-
depends_on: Union[str, Sequence[str], None] = None
|
21
|
-
|
22
|
-
|
23
|
-
def upgrade() -> None:
|
24
|
-
op.create_table(
|
25
|
-
"hat",
|
26
|
-
sa.Column("id", sa.Integer(), nullable=False),
|
27
|
-
sa.Column("title", sa.String(), nullable=False),
|
28
|
-
sa.Column("uri", sa.String(), nullable=False),
|
29
|
-
sa.PrimaryKeyConstraint("id"),
|
30
|
-
sa.UniqueConstraint("title", "uri"),
|
31
|
-
)
|
32
|
-
op.create_table(
|
33
|
-
"contact_sent",
|
34
|
-
sa.Column("id", sa.Integer(), nullable=False),
|
35
|
-
sa.Column("contact_id", sa.Integer(), nullable=False),
|
36
|
-
sa.Column("msg_id", sa.String(), nullable=False),
|
37
|
-
sa.ForeignKeyConstraint(
|
38
|
-
["contact_id"],
|
39
|
-
["contact.id"],
|
40
|
-
),
|
41
|
-
sa.PrimaryKeyConstraint("id"),
|
42
|
-
sa.UniqueConstraint("contact_id", "msg_id"),
|
43
|
-
)
|
44
|
-
op.create_table(
|
45
|
-
"participant",
|
46
|
-
sa.Column("id", sa.Integer(), nullable=False),
|
47
|
-
sa.Column("room_id", sa.Integer(), nullable=False),
|
48
|
-
sa.Column("contact_id", sa.Integer(), nullable=True),
|
49
|
-
sa.Column("is_user", sa.Boolean(), nullable=False),
|
50
|
-
sa.Column(
|
51
|
-
"affiliation",
|
52
|
-
sa.Enum("outcast", "member", "admin", "owner", "none", native_enum=False),
|
53
|
-
nullable=False,
|
54
|
-
),
|
55
|
-
sa.Column(
|
56
|
-
"role",
|
57
|
-
sa.Enum("moderator", "participant", "visitor", "none", native_enum=False),
|
58
|
-
nullable=False,
|
59
|
-
),
|
60
|
-
sa.Column("presence_sent", sa.Boolean(), nullable=False),
|
61
|
-
sa.Column("resource", sa.String(), nullable=True),
|
62
|
-
sa.Column("nickname", sa.String(), nullable=True),
|
63
|
-
sa.Column("extra_attributes", slidge.db.meta.JSONEncodedDict(), nullable=True),
|
64
|
-
sa.ForeignKeyConstraint(
|
65
|
-
["contact_id"],
|
66
|
-
["contact.id"],
|
67
|
-
),
|
68
|
-
sa.ForeignKeyConstraint(
|
69
|
-
["room_id"],
|
70
|
-
["room.id"],
|
71
|
-
),
|
72
|
-
sa.PrimaryKeyConstraint("id"),
|
73
|
-
)
|
74
|
-
op.create_table(
|
75
|
-
"participant_hats",
|
76
|
-
sa.Column("participant_id", sa.Integer(), nullable=False),
|
77
|
-
sa.Column("hat_id", sa.Integer(), nullable=False),
|
78
|
-
sa.ForeignKeyConstraint(
|
79
|
-
["hat_id"],
|
80
|
-
["hat.id"],
|
81
|
-
),
|
82
|
-
sa.ForeignKeyConstraint(
|
83
|
-
["participant_id"],
|
84
|
-
["participant.id"],
|
85
|
-
),
|
86
|
-
sa.PrimaryKeyConstraint("participant_id", "hat_id"),
|
87
|
-
)
|
88
|
-
op.add_column("contact", sa.Column("is_friend", sa.Boolean(), nullable=False))
|
89
|
-
op.add_column("contact", sa.Column("added_to_roster", sa.Boolean(), nullable=False))
|
90
|
-
op.add_column(
|
91
|
-
"contact",
|
92
|
-
sa.Column("extra_attributes", slidge.db.meta.JSONEncodedDict(), nullable=True),
|
93
|
-
)
|
94
|
-
op.add_column("contact", sa.Column("updated", sa.Boolean(), nullable=False))
|
95
|
-
op.add_column("room", sa.Column("description", sa.String(), nullable=True))
|
96
|
-
op.add_column("room", sa.Column("subject", sa.String(), nullable=True))
|
97
|
-
op.add_column("room", sa.Column("subject_date", sa.DateTime(), nullable=True))
|
98
|
-
|
99
|
-
if op.get_bind().engine.name == "postgresql":
|
100
|
-
op.execute(
|
101
|
-
"CREATE TYPE muctype AS ENUM ('GROUP', 'CHANNEL', 'CHANNEL_NON_ANONYMOUS')"
|
102
|
-
)
|
103
|
-
|
104
|
-
op.add_column(
|
105
|
-
"room",
|
106
|
-
sa.Column(
|
107
|
-
"muc_type",
|
108
|
-
sa.Enum("GROUP", "CHANNEL", "CHANNEL_NON_ANONYMOUS", name="muctype"),
|
109
|
-
nullable=True,
|
110
|
-
),
|
111
|
-
)
|
112
|
-
op.add_column("room", sa.Column("user_resources", sa.String(), nullable=True))
|
113
|
-
op.add_column(
|
114
|
-
"room", sa.Column("participants_filled", sa.Boolean(), nullable=False)
|
115
|
-
)
|
116
|
-
op.add_column(
|
117
|
-
"room",
|
118
|
-
sa.Column("extra_attributes", slidge.db.meta.JSONEncodedDict(), nullable=True),
|
119
|
-
)
|
120
|
-
op.add_column("room", sa.Column("updated", sa.Boolean(), nullable=False))
|
121
|
-
|
122
|
-
|
123
|
-
def downgrade() -> None:
|
124
|
-
op.drop_column("room", "updated")
|
125
|
-
op.drop_column("room", "extra_attributes")
|
126
|
-
op.drop_column("room", "participants_filled")
|
127
|
-
op.drop_column("room", "user_resources")
|
128
|
-
op.drop_column("room", "muc_type")
|
129
|
-
op.drop_column("room", "subject_date")
|
130
|
-
op.drop_column("room", "subject")
|
131
|
-
op.drop_column("room", "description")
|
132
|
-
op.drop_column("contact", "updated")
|
133
|
-
op.drop_column("contact", "extra_attributes")
|
134
|
-
op.drop_column("contact", "added_to_roster")
|
135
|
-
op.drop_column("contact", "is_friend")
|
136
|
-
op.drop_table("participant_hats")
|
137
|
-
op.drop_table("participant")
|
138
|
-
op.drop_table("contact_sent")
|
139
|
-
op.drop_table("hat")
|
@@ -1,50 +0,0 @@
|
|
1
|
-
"""DB Creation
|
2
|
-
|
3
|
-
Including a migration from the user_store shelf
|
4
|
-
|
5
|
-
Revision ID: aa9d82a7f6ef
|
6
|
-
Revises:
|
7
|
-
Create Date: 2024-04-17 20:57:01.357041
|
8
|
-
|
9
|
-
"""
|
10
|
-
|
11
|
-
from typing import Sequence, Union
|
12
|
-
|
13
|
-
import sqlalchemy as sa
|
14
|
-
from alembic import op
|
15
|
-
|
16
|
-
import slidge.db.meta
|
17
|
-
|
18
|
-
# revision identifiers, used by Alembic.
|
19
|
-
revision: str = "aa9d82a7f6ef"
|
20
|
-
down_revision: Union[str, None] = None
|
21
|
-
branch_labels: Union[str, Sequence[str], None] = None
|
22
|
-
depends_on: Union[str, Sequence[str], None] = None
|
23
|
-
|
24
|
-
|
25
|
-
def upgrade() -> None:
|
26
|
-
# ### commands auto generated by Alembic - please adjust! ###
|
27
|
-
accounts = op.create_table(
|
28
|
-
"user_account",
|
29
|
-
sa.Column("id", sa.Integer(), nullable=False),
|
30
|
-
sa.Column("jid", slidge.db.meta.JIDType(), nullable=False),
|
31
|
-
sa.Column(
|
32
|
-
"registration_date",
|
33
|
-
sa.DateTime(),
|
34
|
-
server_default=sa.text("(CURRENT_TIMESTAMP)"),
|
35
|
-
nullable=False,
|
36
|
-
),
|
37
|
-
sa.Column(
|
38
|
-
"legacy_module_data", slidge.db.meta.JSONEncodedDict(), nullable=False
|
39
|
-
),
|
40
|
-
sa.Column("preferences", slidge.db.meta.JSONEncodedDict(), nullable=False),
|
41
|
-
sa.PrimaryKeyConstraint("id"),
|
42
|
-
sa.UniqueConstraint("jid"),
|
43
|
-
)
|
44
|
-
# ### end Alembic commands ###
|
45
|
-
|
46
|
-
|
47
|
-
def downgrade() -> None:
|
48
|
-
# ### commands auto generated by Alembic - please adjust! ###
|
49
|
-
op.drop_table("user_account")
|
50
|
-
# ### end Alembic commands ###
|
@@ -1,79 +0,0 @@
|
|
1
|
-
"""Store avatar legacy ID in the Contact and Room table
|
2
|
-
|
3
|
-
Revision ID: abba1ae0edb3
|
4
|
-
Revises: 8b993243a536
|
5
|
-
Create Date: 2024-07-29 15:44:41.557388
|
6
|
-
|
7
|
-
"""
|
8
|
-
|
9
|
-
from typing import Sequence, Union
|
10
|
-
|
11
|
-
import sqlalchemy as sa
|
12
|
-
from alembic import op
|
13
|
-
|
14
|
-
from slidge.db.models import Contact, Room
|
15
|
-
|
16
|
-
# revision identifiers, used by Alembic.
|
17
|
-
revision: str = "abba1ae0edb3"
|
18
|
-
down_revision: Union[str, None] = "8b993243a536"
|
19
|
-
branch_labels: Union[str, Sequence[str], None] = None
|
20
|
-
depends_on: Union[str, Sequence[str], None] = None
|
21
|
-
|
22
|
-
|
23
|
-
def upgrade() -> None:
|
24
|
-
conn = op.get_bind()
|
25
|
-
room_avatars = conn.execute(
|
26
|
-
sa.text(
|
27
|
-
"select room.id, avatar.legacy_id from room join avatar on room.avatar_id = avatar.id"
|
28
|
-
)
|
29
|
-
).all()
|
30
|
-
contact_avatars = conn.execute(
|
31
|
-
sa.text(
|
32
|
-
"select contact.id, avatar.legacy_id from contact join avatar on contact.avatar_id = avatar.id"
|
33
|
-
)
|
34
|
-
).all()
|
35
|
-
with op.batch_alter_table("contact", schema=None) as batch_op:
|
36
|
-
batch_op.add_column(sa.Column("avatar_legacy_id", sa.String(), nullable=True))
|
37
|
-
|
38
|
-
with op.batch_alter_table("room", schema=None) as batch_op:
|
39
|
-
batch_op.add_column(sa.Column("avatar_legacy_id", sa.String(), nullable=True))
|
40
|
-
if op.get_bind().engine.name != "postgresql":
|
41
|
-
batch_op.create_unique_constraint(
|
42
|
-
"uq_room_user_account_id_jid", ["user_account_id", "jid"]
|
43
|
-
)
|
44
|
-
batch_op.create_unique_constraint(
|
45
|
-
"uq_room_user_account_id_legacy_id", ["user_account_id", "legacy_id"]
|
46
|
-
)
|
47
|
-
|
48
|
-
for room_pk, avatar_legacy_id in room_avatars:
|
49
|
-
conn.execute(
|
50
|
-
sa.update(Room)
|
51
|
-
.where(Room.id == room_pk)
|
52
|
-
.values(avatar_legacy_id=avatar_legacy_id)
|
53
|
-
)
|
54
|
-
for contact_pk, avatar_legacy_id in contact_avatars:
|
55
|
-
conn.execute(
|
56
|
-
sa.update(Contact)
|
57
|
-
.where(Contact.id == contact_pk)
|
58
|
-
.values(avatar_legacy_id=avatar_legacy_id)
|
59
|
-
)
|
60
|
-
# conn.commit()
|
61
|
-
|
62
|
-
with op.batch_alter_table("avatar", schema=None) as batch_op:
|
63
|
-
batch_op.drop_column("legacy_id")
|
64
|
-
|
65
|
-
|
66
|
-
def downgrade() -> None:
|
67
|
-
# ### commands auto generated by Alembic - please adjust! ###
|
68
|
-
with op.batch_alter_table("room", schema=None) as batch_op:
|
69
|
-
batch_op.drop_constraint("uq_room_user_account_id_legacy_id", type_="unique")
|
70
|
-
batch_op.drop_constraint("uq_room_user_account_id_jid", type_="unique")
|
71
|
-
batch_op.drop_column("avatar_legacy_id")
|
72
|
-
|
73
|
-
with op.batch_alter_table("contact", schema=None) as batch_op:
|
74
|
-
batch_op.drop_column("avatar_legacy_id")
|
75
|
-
|
76
|
-
with op.batch_alter_table("avatar", schema=None) as batch_op:
|
77
|
-
batch_op.add_column(sa.Column("legacy_id", sa.VARCHAR(), nullable=True))
|
78
|
-
|
79
|
-
# ### end Alembic commands ###
|
@@ -1,214 +0,0 @@
|
|
1
|
-
"""Move everything to persistent DB
|
2
|
-
|
3
|
-
Revision ID: b33993e87db3
|
4
|
-
Revises: e91195719c2c
|
5
|
-
Create Date: 2024-06-25 16:09:36.663953
|
6
|
-
|
7
|
-
"""
|
8
|
-
|
9
|
-
import shutil
|
10
|
-
from typing import Sequence, Union
|
11
|
-
|
12
|
-
import sqlalchemy as sa
|
13
|
-
from alembic import op
|
14
|
-
|
15
|
-
import slidge.db.meta
|
16
|
-
from slidge import global_config
|
17
|
-
|
18
|
-
# revision identifiers, used by Alembic.
|
19
|
-
revision: str = "b33993e87db3"
|
20
|
-
down_revision: Union[str, None] = "e91195719c2c"
|
21
|
-
branch_labels: Union[str, Sequence[str], None] = None
|
22
|
-
depends_on: Union[str, Sequence[str], None] = None
|
23
|
-
|
24
|
-
|
25
|
-
def upgrade() -> None:
|
26
|
-
# ### commands auto generated by Alembic - please adjust! ###
|
27
|
-
op.create_table(
|
28
|
-
"avatar",
|
29
|
-
sa.Column("id", sa.Integer(), nullable=False),
|
30
|
-
sa.Column("filename", sa.String(), nullable=False),
|
31
|
-
sa.Column("hash", sa.String(), nullable=False),
|
32
|
-
sa.Column("height", sa.Integer(), nullable=False),
|
33
|
-
sa.Column("width", sa.Integer(), nullable=False),
|
34
|
-
sa.Column("legacy_id", sa.String(), nullable=True),
|
35
|
-
sa.Column("url", sa.String(), nullable=True),
|
36
|
-
sa.Column("etag", sa.String(), nullable=True),
|
37
|
-
sa.Column("last_modified", sa.String(), nullable=True),
|
38
|
-
sa.PrimaryKeyConstraint("id"),
|
39
|
-
sa.UniqueConstraint("filename"),
|
40
|
-
sa.UniqueConstraint("hash"),
|
41
|
-
sa.UniqueConstraint("legacy_id"),
|
42
|
-
)
|
43
|
-
op.create_table(
|
44
|
-
"attachment",
|
45
|
-
sa.Column("id", sa.Integer(), nullable=False),
|
46
|
-
sa.Column("user_account_id", sa.Integer(), nullable=False),
|
47
|
-
sa.Column("legacy_file_id", sa.String(), nullable=True),
|
48
|
-
sa.Column("url", sa.String(), nullable=False),
|
49
|
-
sa.Column("sims", sa.String(), nullable=True),
|
50
|
-
sa.Column("sfs", sa.String(), nullable=True),
|
51
|
-
sa.ForeignKeyConstraint(
|
52
|
-
["user_account_id"],
|
53
|
-
["user_account.id"],
|
54
|
-
),
|
55
|
-
sa.PrimaryKeyConstraint("id"),
|
56
|
-
)
|
57
|
-
op.create_index(
|
58
|
-
op.f("ix_attachment_legacy_file_id"),
|
59
|
-
"attachment",
|
60
|
-
["legacy_file_id"],
|
61
|
-
unique=False,
|
62
|
-
)
|
63
|
-
op.create_index(op.f("ix_attachment_url"), "attachment", ["url"], unique=False)
|
64
|
-
op.create_table(
|
65
|
-
"contact",
|
66
|
-
sa.Column("id", sa.Integer(), nullable=False),
|
67
|
-
sa.Column("user_account_id", sa.Integer(), nullable=False),
|
68
|
-
sa.Column("legacy_id", sa.String(), nullable=False),
|
69
|
-
sa.Column("jid", slidge.db.meta.JIDType(), nullable=False),
|
70
|
-
sa.Column("avatar_id", sa.Integer(), nullable=True),
|
71
|
-
sa.Column("nick", sa.String(), nullable=True),
|
72
|
-
sa.Column("cached_presence", sa.Boolean(), nullable=False),
|
73
|
-
sa.Column("last_seen", sa.DateTime(), nullable=True),
|
74
|
-
sa.Column("ptype", sa.String(), nullable=True),
|
75
|
-
sa.Column("pstatus", sa.String(), nullable=True),
|
76
|
-
sa.Column("pshow", sa.String(), nullable=True),
|
77
|
-
sa.ForeignKeyConstraint(
|
78
|
-
["avatar_id"],
|
79
|
-
["avatar.id"],
|
80
|
-
),
|
81
|
-
sa.ForeignKeyConstraint(
|
82
|
-
["user_account_id"],
|
83
|
-
["user_account.id"],
|
84
|
-
),
|
85
|
-
sa.PrimaryKeyConstraint("id"),
|
86
|
-
sa.UniqueConstraint("user_account_id", "jid"),
|
87
|
-
sa.UniqueConstraint("user_account_id", "legacy_id"),
|
88
|
-
)
|
89
|
-
op.create_table(
|
90
|
-
"legacy_ids_multi",
|
91
|
-
sa.Column("id", sa.Integer(), nullable=False),
|
92
|
-
sa.Column("user_account_id", sa.Integer(), nullable=False),
|
93
|
-
sa.Column("legacy_id", sa.String(), nullable=False),
|
94
|
-
sa.ForeignKeyConstraint(
|
95
|
-
["user_account_id"],
|
96
|
-
["user_account.id"],
|
97
|
-
),
|
98
|
-
sa.PrimaryKeyConstraint("id"),
|
99
|
-
)
|
100
|
-
op.create_index(
|
101
|
-
"legacy_ids_multi_user_account_id_legacy_id",
|
102
|
-
"legacy_ids_multi",
|
103
|
-
["user_account_id", "legacy_id"],
|
104
|
-
unique=True,
|
105
|
-
)
|
106
|
-
op.create_table(
|
107
|
-
"room",
|
108
|
-
sa.Column("id", sa.Integer(), nullable=False),
|
109
|
-
sa.Column("user_account_id", sa.Integer(), nullable=False),
|
110
|
-
sa.Column("legacy_id", sa.String(), nullable=False),
|
111
|
-
sa.Column("jid", slidge.db.meta.JIDType(), nullable=False),
|
112
|
-
sa.Column("avatar_id", sa.Integer(), nullable=True),
|
113
|
-
sa.Column("name", sa.String(), nullable=True),
|
114
|
-
sa.ForeignKeyConstraint(
|
115
|
-
["avatar_id"],
|
116
|
-
["avatar.id"],
|
117
|
-
),
|
118
|
-
sa.ForeignKeyConstraint(
|
119
|
-
["user_account_id"],
|
120
|
-
["user_account.id"],
|
121
|
-
),
|
122
|
-
sa.PrimaryKeyConstraint("id"),
|
123
|
-
sa.UniqueConstraint("jid"),
|
124
|
-
sa.UniqueConstraint("legacy_id"),
|
125
|
-
)
|
126
|
-
op.create_table(
|
127
|
-
"xmpp_to_legacy_ids",
|
128
|
-
sa.Column("id", sa.Integer(), nullable=False),
|
129
|
-
sa.Column("user_account_id", sa.Integer(), nullable=False),
|
130
|
-
sa.Column("xmpp_id", sa.String(), nullable=False),
|
131
|
-
sa.Column("legacy_id", sa.String(), nullable=False),
|
132
|
-
sa.Column(
|
133
|
-
"type",
|
134
|
-
sa.Enum("DM", "GROUP_CHAT", "THREAD", name="xmpptolegacyenum"),
|
135
|
-
nullable=False,
|
136
|
-
),
|
137
|
-
sa.ForeignKeyConstraint(
|
138
|
-
["user_account_id"],
|
139
|
-
["user_account.id"],
|
140
|
-
),
|
141
|
-
sa.PrimaryKeyConstraint("id"),
|
142
|
-
)
|
143
|
-
op.create_index(
|
144
|
-
"xmpp_legacy",
|
145
|
-
"xmpp_to_legacy_ids",
|
146
|
-
["user_account_id", "xmpp_id", "legacy_id"],
|
147
|
-
unique=True,
|
148
|
-
)
|
149
|
-
op.create_table(
|
150
|
-
"mam",
|
151
|
-
sa.Column("id", sa.Integer(), nullable=False),
|
152
|
-
sa.Column("room_id", sa.Integer(), nullable=False),
|
153
|
-
sa.Column("stanza_id", sa.String(), nullable=False),
|
154
|
-
sa.Column("timestamp", sa.DateTime(), nullable=False),
|
155
|
-
sa.Column("author_jid", slidge.db.meta.JIDType(), nullable=False),
|
156
|
-
sa.Column("stanza", sa.String(), nullable=False),
|
157
|
-
sa.ForeignKeyConstraint(
|
158
|
-
["room_id"],
|
159
|
-
["room.id"],
|
160
|
-
),
|
161
|
-
sa.PrimaryKeyConstraint("id"),
|
162
|
-
sa.UniqueConstraint("room_id", "stanza_id"),
|
163
|
-
)
|
164
|
-
op.create_table(
|
165
|
-
"xmpp_ids_multi",
|
166
|
-
sa.Column("id", sa.Integer(), nullable=False),
|
167
|
-
sa.Column("user_account_id", sa.Integer(), nullable=False),
|
168
|
-
sa.Column("xmpp_id", sa.String(), nullable=False),
|
169
|
-
sa.Column("legacy_ids_multi_id", sa.Integer(), nullable=False),
|
170
|
-
sa.ForeignKeyConstraint(
|
171
|
-
["legacy_ids_multi_id"],
|
172
|
-
["legacy_ids_multi.id"],
|
173
|
-
),
|
174
|
-
sa.ForeignKeyConstraint(
|
175
|
-
["user_account_id"],
|
176
|
-
["user_account.id"],
|
177
|
-
),
|
178
|
-
sa.PrimaryKeyConstraint("id"),
|
179
|
-
)
|
180
|
-
op.create_index(
|
181
|
-
"legacy_ids_multi_user_account_id_xmpp_id",
|
182
|
-
"xmpp_ids_multi",
|
183
|
-
["user_account_id", "xmpp_id"],
|
184
|
-
unique=True,
|
185
|
-
)
|
186
|
-
|
187
|
-
try:
|
188
|
-
shutil.rmtree(global_config.HOME_DIR / "slidge_avatars_v2")
|
189
|
-
except (FileNotFoundError, AttributeError):
|
190
|
-
pass
|
191
|
-
|
192
|
-
# ### end Alembic commands ###
|
193
|
-
|
194
|
-
|
195
|
-
def downgrade() -> None:
|
196
|
-
# ### commands auto generated by Alembic - please adjust! ###
|
197
|
-
op.drop_index(
|
198
|
-
"legacy_ids_multi_user_account_id_xmpp_id", table_name="xmpp_ids_multi"
|
199
|
-
)
|
200
|
-
op.drop_table("xmpp_ids_multi")
|
201
|
-
op.drop_table("mam")
|
202
|
-
op.drop_index("xmpp_legacy", table_name="xmpp_to_legacy_ids")
|
203
|
-
op.drop_table("xmpp_to_legacy_ids")
|
204
|
-
op.drop_table("room")
|
205
|
-
op.drop_index(
|
206
|
-
"legacy_ids_multi_user_account_id_legacy_id", table_name="legacy_ids_multi"
|
207
|
-
)
|
208
|
-
op.drop_table("legacy_ids_multi")
|
209
|
-
op.drop_table("contact")
|
210
|
-
op.drop_index(op.f("ix_attachment_url"), table_name="attachment")
|
211
|
-
op.drop_index(op.f("ix_attachment_legacy_file_id"), table_name="attachment")
|
212
|
-
op.drop_table("attachment")
|
213
|
-
op.drop_table("avatar")
|
214
|
-
# ### end Alembic commands ###
|