feat: plantilla base workspace SaaS
This commit is contained in:
54
backend/alembic/versions/g2h3i4j5k6l7_add_invite_codes.py
Normal file
54
backend/alembic/versions/g2h3i4j5k6l7_add_invite_codes.py
Normal file
@@ -0,0 +1,54 @@
|
||||
"""add invite codes
|
||||
|
||||
Revision ID: g2h3i4j5k6l7
|
||||
Revises: c3d4e5f6a7b
|
||||
Create Date: 2026-06-02 00:00:00.000000
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
revision: str = "g2h3i4j5k6l7"
|
||||
down_revision: str = "c3d4e5f6a7b"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.create_table(
|
||||
"invite_codes",
|
||||
sa.Column("id", sa.Integer(), nullable=False),
|
||||
sa.Column("code", sa.String(length=16), nullable=False),
|
||||
sa.Column("tenant_slug", sa.String(length=100), nullable=False),
|
||||
sa.Column("company_id", sa.Integer(), nullable=True),
|
||||
sa.Column("role", sa.String(length=50), nullable=False, server_default="user"),
|
||||
sa.Column("max_uses", sa.Integer(), nullable=True),
|
||||
sa.Column("uses_count", sa.Integer(), nullable=False, server_default="0"),
|
||||
sa.Column("expires_at", sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column("created_by", sa.String(length=255), nullable=False),
|
||||
sa.Column("is_active", sa.Boolean(), nullable=False, server_default="true"),
|
||||
sa.Column("created_at", sa.DateTime(), nullable=True, server_default=sa.text("now()")),
|
||||
sa.Column("updated_at", sa.DateTime(), nullable=True, server_default=sa.text("now()")),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
schema="core",
|
||||
)
|
||||
op.create_index("ix_core_invite_codes_id", "invite_codes", ["id"], schema="core")
|
||||
op.create_index(
|
||||
"ix_core_invite_codes_code", "invite_codes", ["code"], unique=True, schema="core"
|
||||
)
|
||||
op.create_index(
|
||||
"ix_core_invite_codes_tenant_slug", "invite_codes", ["tenant_slug"], schema="core"
|
||||
)
|
||||
op.create_index(
|
||||
"ix_core_invite_codes_company_id", "invite_codes", ["company_id"], schema="core"
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_index("ix_core_invite_codes_company_id", table_name="invite_codes", schema="core")
|
||||
op.drop_index("ix_core_invite_codes_tenant_slug", table_name="invite_codes", schema="core")
|
||||
op.drop_index("ix_core_invite_codes_code", table_name="invite_codes", schema="core")
|
||||
op.drop_index("ix_core_invite_codes_id", table_name="invite_codes", schema="core")
|
||||
op.drop_table("invite_codes", schema="core")
|
||||
Reference in New Issue
Block a user