Initial commit - Migrated to Dev environment
This commit is contained in:
38
migrations/versions/10b73fee8967_fix_roles_and_universal_vehicles.py
Executable file
38
migrations/versions/10b73fee8967_fix_roles_and_universal_vehicles.py
Executable file
@@ -0,0 +1,38 @@
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
revision = "10b73fee8967"
|
||||
down_revision = "13d050e8cf6d"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
def upgrade() -> None:
|
||||
# 1. Régi táblák eltávolítása kényszerítve
|
||||
tables_to_drop = [
|
||||
"user_badges", "badges", "points_ledger", "votes", "user_scores",
|
||||
"user_stats", "competitions", "level_configs", "point_rules",
|
||||
"regional_settings", "translations", "system_settings", "vehicles"
|
||||
]
|
||||
for table in tables_to_drop:
|
||||
op.execute(f"DROP TABLE IF EXISTS data.{table} CASCADE")
|
||||
|
||||
# 2. Szerepkör oszlop típusának módosítása
|
||||
op.execute("ALTER TABLE data.organization_members ALTER COLUMN role TYPE orguserrole USING role::text::orguserrole")
|
||||
|
||||
# 3. Új oszlopok hozzáadása (Szigorúan Sima Idézőjellel a DEFAULT-nál!)
|
||||
op.execute("ALTER TABLE data.users ADD COLUMN IF NOT EXISTS hashed_password VARCHAR")
|
||||
op.execute("ALTER TABLE data.users ADD COLUMN IF NOT EXISTS role VARCHAR DEFAULT \u0027user\u0027")
|
||||
op.execute("ALTER TABLE data.users ADD COLUMN IF NOT EXISTS is_superuser BOOLEAN DEFAULT FALSE")
|
||||
op.execute("ALTER TABLE data.users ADD COLUMN IF NOT EXISTS is_company BOOLEAN DEFAULT FALSE")
|
||||
op.execute("ALTER TABLE data.users ADD COLUMN IF NOT EXISTS updated_at TIMESTAMP WITH TIME ZONE")
|
||||
|
||||
op.execute("ALTER TABLE data.organizations ADD COLUMN IF NOT EXISTS theme VARCHAR DEFAULT \u0027system\u0027")
|
||||
op.execute("ALTER TABLE data.organizations ADD COLUMN IF NOT EXISTS is_active BOOLEAN DEFAULT TRUE")
|
||||
|
||||
# 4. Takarítás
|
||||
op.execute("ALTER TABLE data.users DROP COLUMN IF EXISTS password_hash")
|
||||
op.execute("ALTER TABLE data.users DROP COLUMN IF EXISTS is_email_verified")
|
||||
|
||||
def downgrade() -> None:
|
||||
pass
|
||||
Reference in New Issue
Block a user