gitscope
← marzneshin / v0.4.1 / app/db/migrations/versions/9001356f0063_create_settings.py
https://dev.kronoz.win/r/marzneshin.git
app/db/migrations/versions/9001356f0063_create_settings.py · Python
Blame Raw
 1"""empty message
 2
 3Revision ID: 9001356f0063
 4Revises: 058eb11c5b17
 5Create Date: 2024-06-08 21:59:45.214144
 6
 7"""
 8
 9import sqlalchemy as sa
10from alembic import op
11
12# revision identifiers, used by Alembic.
13revision = "9001356f0063"
14down_revision = "058eb11c5b17"
15branch_labels = None
16depends_on = None
17
18
19def upgrade() -> None:
20    # ### commands auto generated by Alembic - please adjust! ###
21    settings_table = op.create_table(
22        "settings",
23        sa.Column("id", sa.Integer(), nullable=False),
24        sa.Column("subscription", sa.JSON(), nullable=False),
25        sa.Column("telegram", sa.JSON()),
26        sa.PrimaryKeyConstraint("id"),
27    )
28    # ### end Alembic commands ###
29    op.bulk_insert(
30        settings_table,
31        [
32            {
33                "telegram": None,
34                "subscription": {
35                    "template_on_acceptance": True,
36                    "profile_title": "Support",
37                    "support_link": "t.me/support",
38                    "update_interval": 12,
39                    "rules": [
40                        {
41                            "pattern": "^([Cc]lash-verge|[Cc]lash-?[Mm]eta)",
42                            "result": "clash-meta",
43                        },
44                        {"pattern": "^([Cc]lash|[Ss]tash)", "result": "clash"},
45                        {
46                            "pattern": "^(SFA|SFI|SFM|SFT|[Kk]aring|[Hh]iddify[Nn]ext)",
47                            "result": "sing-box",
48                        },
49                        {
50                            "pattern": "^v2rayN/(:?6\.(:?[5-9]\d+|4[1-9])|[7-9]\d*\.\d+)",
51                            "result": "xray",
52                        },
53                        {"pattern": "^v2rayN/", "result": "base64-links"},
54                        {
55                            "pattern": "^v2rayNG/([2-9]|1\.(9|\d{2,})|1\.8\.(1[7-9]|[2-9]\d|\d{3,}))",
56                            "result": "xray",
57                        },
58                        {"pattern": "^v2rayNG/", "result": "base64-links"},
59                        {"pattern": "^[Ss]treisand", "result": "xray"},
60                        {"pattern": ".*", "result": "base64-links"},
61                    ],
62                },
63            }
64        ],
65    )
66
67
68def downgrade() -> None:
69    # ### commands auto generated by Alembic - please adjust! ###
70    op.drop_table("settings")
71    # ### end Alembic commands ###