mirror of
https://git.victorphan.net/basketballcantho/ten-project.git
synced 2026-08-05 13:03:10 +07:00
thực hiện phân quyền admin giáo viên và học sinh xong
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
"""add role and status to users
|
||||
|
||||
Revision ID: 0002_add_role_status
|
||||
Revises: 0001_initial_schema
|
||||
Create Date: 2026-04-01
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = "0002_add_role_status"
|
||||
down_revision = "0001"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
user_role = postgresql.ENUM("admin", "teacher", "student", name="user_role")
|
||||
user_status = postgresql.ENUM("pending", "approved", "rejected", name="user_status")
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
user_role.create(op.get_bind(), checkfirst=True)
|
||||
user_status.create(op.get_bind(), checkfirst=True)
|
||||
|
||||
op.add_column(
|
||||
"users",
|
||||
sa.Column(
|
||||
"role",
|
||||
sa.Enum("admin", "teacher", "student", name="user_role"),
|
||||
nullable=False,
|
||||
server_default="student",
|
||||
),
|
||||
)
|
||||
op.add_column(
|
||||
"users",
|
||||
sa.Column(
|
||||
"status",
|
||||
sa.Enum("pending", "approved", "rejected", name="user_status"),
|
||||
nullable=False,
|
||||
server_default="pending",
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_column("users", "status")
|
||||
op.drop_column("users", "role")
|
||||
user_role.drop(op.get_bind(), checkfirst=True)
|
||||
user_status.drop(op.get_bind(), checkfirst=True)
|
||||
Reference in New Issue
Block a user