first commit
This commit is contained in:
commit
34ea15a54d
246 changed files with 18660 additions and 0 deletions
|
|
@ -0,0 +1,56 @@
|
|||
"""admin roles, subscribers, alert log
|
||||
|
||||
Revision ID: 20260404_0003
|
||||
Revises: 20260404_0002
|
||||
"""
|
||||
|
||||
from typing import Sequence, Union
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
revision: str = "20260404_0003"
|
||||
down_revision: Union[str, None] = "20260404_0002"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.execute(
|
||||
"""
|
||||
DO $$ BEGIN
|
||||
CREATE TYPE adminrole AS ENUM ('super_admin', 'editor');
|
||||
EXCEPTION
|
||||
WHEN duplicate_object THEN null;
|
||||
END $$;
|
||||
"""
|
||||
)
|
||||
op.execute(
|
||||
"ALTER TABLE admin_users ADD COLUMN IF NOT EXISTS role adminrole NOT NULL DEFAULT 'super_admin'"
|
||||
)
|
||||
|
||||
op.execute(
|
||||
"""
|
||||
CREATE TABLE IF NOT EXISTS newsletter_subscribers (
|
||||
id SERIAL PRIMARY KEY,
|
||||
email VARCHAR(255) NOT NULL UNIQUE,
|
||||
neighborhood VARCHAR(120),
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
||||
)
|
||||
"""
|
||||
)
|
||||
op.execute(
|
||||
"""
|
||||
CREATE TABLE IF NOT EXISTS alert_dispatches (
|
||||
id SERIAL PRIMARY KEY,
|
||||
alert_key VARCHAR(120) NOT NULL UNIQUE,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
||||
)
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.execute("DROP TABLE IF EXISTS alert_dispatches")
|
||||
op.execute("DROP TABLE IF EXISTS newsletter_subscribers")
|
||||
op.execute("ALTER TABLE admin_users DROP COLUMN IF EXISTS role")
|
||||
Loading…
Add table
Add a link
Reference in a new issue