From 935bbc18f672b23f164791a18c657cac81ab0612 Mon Sep 17 00:00:00 2001 From: Furqan-14 Date: Sat, 17 Jan 2026 16:36:05 +0530 Subject: [PATCH] fix: port change and DB urls --- .env.development | 6 +- .env.local | 4 +- .env.testing | 6 +- .../8acd83604252_initial_migration.py | 132 ++++++++++++++++++ scripts/seed_palettes.py | 2 +- scripts/seed_superadmin.py | 8 +- 6 files changed, 145 insertions(+), 13 deletions(-) create mode 100644 alembic/versions/8acd83604252_initial_migration.py diff --git a/.env.development b/.env.development index 5710323..89a9c97 100644 --- a/.env.development +++ b/.env.development @@ -1,13 +1,13 @@ # Project Configuration PROJECT_NAME=SaaS Architecture VERSION=1.0.0 -PORT=11001 +PORT=10001 APP_ENV=development SECRET_KEY="Usu9Qmg4ppRexR6Xp657MMMHsoOaiV8cPqlY_THWNaPhGT6DN9Xd8UO4zG3kWjwIqW9hPa5bYwQUoDhyRlzv_w" ALLOWED_HOSTS=* HOST=127.0.0.1 -FRONTEND_URL=https://fulfilment-dev.maskantech.in -CORS_ALLOWED_ORIGINS=https://fulfilment-dev.maskantech.in +FRONTEND_URL=https://saas-dev.maskantech.in +CORS_ALLOWED_ORIGINS=https://saas-dev.maskantech.in # Security ENCRYPTION_KEY="1cd1dc2d42afc5606e224df1108162db2d6ca372a45a9b8d278162f6006236d5" diff --git a/.env.local b/.env.local index 1071e05..f86d4ac 100644 --- a/.env.local +++ b/.env.local @@ -20,8 +20,8 @@ SUPER_ADMIN_LAST_NAME=Admin #Database Configuration DB_SSL=False -DATABASE_URL=postgresql://saas_user:nMCuFvGoG%28%23Q%40Q4%5E@106.51.104.95:5432/saas_local - +DATABASE_URL=postgresql://saas_user:K9uR3mZpQ7~W4F2YH8A_tLxD@106.51.104.95:5432/saas_local + # Redis Configuration # REDIS_URL="" # port="" diff --git a/.env.testing b/.env.testing index 96f3595..fbccb3f 100644 --- a/.env.testing +++ b/.env.testing @@ -1,13 +1,13 @@ # Project Configuration PROJECT_NAME=SaaS Architecture VERSION=1.0.0 -PORT=11002 +PORT=10002 APP_ENV=testing SECRET_KEY="Usu9Qmg4ppRexR6Xp657MMMHsoOaiV8cPqlY_THWNaPhGT6DN9Xd8UO4zG3kWjwIqW9hPa5bYwQUoDhyRlzv_w" ALLOWED_HOSTS=* HOST=127.0.0.1 -FRONTEND_URL=https://fulfilment-test.maskantech.in -CORS_ALLOWED_ORIGINS=https://fulfilment-test.maskantech.in +FRONTEND_URL=https://saas-test.maskantech.in +CORS_ALLOWED_ORIGINS=https://saas-test.maskantech.in # Security ENCRYPTION_KEY="1cd1dc2d42afc5606e224df1108162db2d6ca372a45a9b8d278162f6006236d5" diff --git a/alembic/versions/8acd83604252_initial_migration.py b/alembic/versions/8acd83604252_initial_migration.py new file mode 100644 index 0000000..e1d1d5f --- /dev/null +++ b/alembic/versions/8acd83604252_initial_migration.py @@ -0,0 +1,132 @@ +"""initial migration + +Revision ID: 8acd83604252 +Revises: +Create Date: 2026-01-17 16:23:50.226790 + +""" +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision: str = '8acd83604252' +down_revision: Union[str, Sequence[str], None] = None +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + """Upgrade schema.""" + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('accesses', + sa.Column('id', sa.UUID(), nullable=False), + sa.Column('access_code', sa.String(), nullable=False), + sa.Column('category', sa.String(), nullable=False), + sa.Column('name', sa.String(), nullable=False), + sa.Column('parent_id', sa.UUID(), nullable=True), + sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True), + sa.ForeignKeyConstraint(['parent_id'], ['accesses.id'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_index(op.f('ix_accesses_access_code'), 'accesses', ['access_code'], unique=True) + op.create_index(op.f('ix_accesses_category'), 'accesses', ['category'], unique=False) + op.create_index(op.f('ix_accesses_id'), 'accesses', ['id'], unique=False) + op.create_index(op.f('ix_accesses_parent_id'), 'accesses', ['parent_id'], unique=False) + op.create_table('color_palettes', + sa.Column('id', sa.UUID(), nullable=False), + sa.Column('name', sa.String(), nullable=False), + sa.Column('description', sa.String(), nullable=True), + sa.Column('is_default', sa.Boolean(), nullable=True), + sa.Column('colors', sa.JSON(), nullable=False), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('tenants', + sa.Column('id', sa.UUID(), nullable=False), + sa.Column('tenant_name', sa.String(), nullable=False), + sa.Column('tenant_domain', sa.String(), nullable=False), + sa.Column('tenant_logo_url', sa.String(), nullable=True), + sa.Column('is_active', sa.Boolean(), nullable=False), + sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True), + sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + op.create_index(op.f('ix_tenants_id'), 'tenants', ['id'], unique=False) + op.create_index(op.f('ix_tenants_tenant_domain'), 'tenants', ['tenant_domain'], unique=True) + op.create_index(op.f('ix_tenants_tenant_name'), 'tenants', ['tenant_name'], unique=True) + op.create_table('roles', + sa.Column('id', sa.UUID(), nullable=False), + sa.Column('role_name', sa.String(), nullable=False), + sa.Column('tenant_id', sa.UUID(), nullable=True), + sa.Column('is_default', sa.Boolean(), nullable=True), + sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True), + sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True), + sa.ForeignKeyConstraint(['tenant_id'], ['tenants.id'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_index(op.f('ix_roles_id'), 'roles', ['id'], unique=False) + op.create_index(op.f('ix_roles_tenant_id'), 'roles', ['tenant_id'], unique=False) + op.create_table('role_accesses', + sa.Column('id', sa.UUID(), nullable=False), + sa.Column('role_id', sa.UUID(), nullable=False), + sa.Column('access_id', sa.UUID(), nullable=False), + sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True), + sa.ForeignKeyConstraint(['access_id'], ['accesses.id'], ), + sa.ForeignKeyConstraint(['role_id'], ['roles.id'], ), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('role_id', 'access_id', name='uq_role_access') + ) + op.create_index(op.f('ix_role_accesses_access_id'), 'role_accesses', ['access_id'], unique=False) + op.create_index(op.f('ix_role_accesses_role_id'), 'role_accesses', ['role_id'], unique=False) + op.create_table('users', + sa.Column('id', sa.UUID(), nullable=False), + sa.Column('email', sa.String(), nullable=False), + sa.Column('password', sa.String(), nullable=False), + sa.Column('first_name', sa.String(), nullable=False), + sa.Column('last_name', sa.String(), nullable=True), + sa.Column('phone_number', sa.String(), nullable=True), + sa.Column('preferred_language', sa.String(), nullable=True), + sa.Column('status', sa.String(), nullable=False), + sa.Column('tenant_id', sa.UUID(), nullable=True), + sa.Column('role_id', sa.UUID(), nullable=True), + sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True), + sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True), + sa.Column('password_updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True), + sa.ForeignKeyConstraint(['role_id'], ['roles.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['tenants.id'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_index(op.f('ix_users_email'), 'users', ['email'], unique=True) + op.create_index(op.f('ix_users_id'), 'users', ['id'], unique=False) + op.create_index(op.f('ix_users_role_id'), 'users', ['role_id'], unique=False) + op.create_index(op.f('ix_users_tenant_id'), 'users', ['tenant_id'], unique=False) + # ### end Alembic commands ### + + +def downgrade() -> None: + """Downgrade schema.""" + # ### commands auto generated by Alembic - please adjust! ### + op.drop_index(op.f('ix_users_tenant_id'), table_name='users') + op.drop_index(op.f('ix_users_role_id'), table_name='users') + op.drop_index(op.f('ix_users_id'), table_name='users') + op.drop_index(op.f('ix_users_email'), table_name='users') + op.drop_table('users') + op.drop_index(op.f('ix_role_accesses_role_id'), table_name='role_accesses') + op.drop_index(op.f('ix_role_accesses_access_id'), table_name='role_accesses') + op.drop_table('role_accesses') + op.drop_index(op.f('ix_roles_tenant_id'), table_name='roles') + op.drop_index(op.f('ix_roles_id'), table_name='roles') + op.drop_table('roles') + op.drop_index(op.f('ix_tenants_tenant_name'), table_name='tenants') + op.drop_index(op.f('ix_tenants_tenant_domain'), table_name='tenants') + op.drop_index(op.f('ix_tenants_id'), table_name='tenants') + op.drop_table('tenants') + op.drop_table('color_palettes') + op.drop_index(op.f('ix_accesses_parent_id'), table_name='accesses') + op.drop_index(op.f('ix_accesses_id'), table_name='accesses') + op.drop_index(op.f('ix_accesses_category'), table_name='accesses') + op.drop_index(op.f('ix_accesses_access_code'), table_name='accesses') + op.drop_table('accesses') + # ### end Alembic commands ### diff --git a/scripts/seed_palettes.py b/scripts/seed_palettes.py index ace8231..015bfef 100644 --- a/scripts/seed_palettes.py +++ b/scripts/seed_palettes.py @@ -9,7 +9,7 @@ backend_dir = Path(__file__).resolve().parent.parent sys.path.insert(0, str(backend_dir)) from app.config.database import SessionLocal -from app.models.theme.color_palette_models import ColorPalette +from app.models.theme.color_palette_model import ColorPalette # 1. Default Palette (Dark Navy Sidebar) DEFAULT_PALETTE = { diff --git a/scripts/seed_superadmin.py b/scripts/seed_superadmin.py index 78e03fe..63234cf 100644 --- a/scripts/seed_superadmin.py +++ b/scripts/seed_superadmin.py @@ -18,10 +18,10 @@ from sqlalchemy.orm import Session from app.config.database import SessionLocal from app.config.settings import settings from app.config.security import security -from app.models.auth.user_models import User -from app.models.auth.access_models import Access -from app.models.auth.role_models import Role -from app.models.auth.role_access_models import RoleAccess +from app.models.auth.user_model import User +from app.models.auth.access_model import Access +from app.models.auth.role_model import Role +from app.models.auth.role_access_model import RoleAccess # Predefined accesses (access_code, category, name, parent_code) PREDEFINED_ACCESSES = [