اولین نسخه بک‌اند آرامش پلازا

This commit is contained in:
Behrad
2026-08-27 15:15:12 +03:30
commit 854309f976
26 changed files with 1861 additions and 0 deletions
+50
View File
@@ -0,0 +1,50 @@
import sys
from logging.config import fileConfig
from pathlib import Path
from alembic import context
from sqlalchemy import engine_from_config, pool
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from app.config import settings
from app.database import Base
from app import models # noqa: F401 -- ensures all models are registered on Base.metadata
config = context.config
config.set_main_option("sqlalchemy.url", settings.DATABASE_URL)
if config.config_file_name is not None:
fileConfig(config.config_file_name)
target_metadata = Base.metadata
def run_migrations_offline() -> None:
url = config.get_main_option("sqlalchemy.url")
context.configure(
url=url,
target_metadata=target_metadata,
literal_binds=True,
dialect_opts={"paramstyle": "named"},
)
with context.begin_transaction():
context.run_migrations()
def run_migrations_online() -> None:
connectable = engine_from_config(
config.get_section(config.config_ini_section, {}),
prefix="sqlalchemy.",
poolclass=pool.NullPool,
)
with connectable.connect() as connection:
context.configure(connection=connection, target_metadata=target_metadata)
with context.begin_transaction():
context.run_migrations()
if context.is_offline_mode():
run_migrations_offline()
else:
run_migrations_online()
+24
View File
@@ -0,0 +1,24 @@
"""${message}
Revision ID: ${up_revision}
Revises: ${down_revision | comma,n}
Create Date: ${create_date}
"""
from alembic import op
import sqlalchemy as sa
${imports if imports else ""}
# revision identifiers, used by Alembic.
revision = ${repr(up_revision)}
down_revision = ${repr(down_revision)}
branch_labels = ${repr(branch_labels)}
depends_on = ${repr(depends_on)}
def upgrade() -> None:
${upgrades if upgrades else "pass"}
def downgrade() -> None:
${downgrades if downgrades else "pass"}
@@ -0,0 +1,168 @@
"""initial tables
Revision ID: 55a6f15ea7ef
Revises:
Create Date: 2026-08-26 08:23:45.465259
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '55a6f15ea7ef'
down_revision = None
branch_labels = None
depends_on = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('admin_users',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('username', sa.String(length=64), nullable=False),
sa.Column('hashed_password', sa.String(length=255), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_admin_users_username'), 'admin_users', ['username'], unique=True)
op.create_table('articles',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('slug', sa.String(length=255), nullable=False),
sa.Column('title', sa.String(length=255), nullable=False),
sa.Column('date', sa.String(length=64), nullable=False),
sa.Column('category', sa.String(length=128), nullable=False),
sa.Column('image', sa.String(length=1024), nullable=False),
sa.Column('read', sa.String(length=32), nullable=False),
sa.Column('excerpt', sa.Text(), nullable=False),
sa.Column('body', sa.JSON(), nullable=False),
sa.Column('order', sa.Integer(), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_articles_slug'), 'articles', ['slug'], unique=True)
op.create_table('brand',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=255), nullable=False),
sa.Column('logo', sa.String(length=1024), nullable=False),
sa.Column('hero', sa.String(length=1024), nullable=False),
sa.Column('contact_bg', sa.String(length=1024), nullable=False),
sa.Column('phone', sa.String(length=64), nullable=False),
sa.Column('phone_href', sa.String(length=64), nullable=False),
sa.Column('email', sa.String(length=255), nullable=False),
sa.Column('address', sa.String(length=1024), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_table('contact_leads',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=255), nullable=False),
sa.Column('phone', sa.String(length=64), nullable=False),
sa.Column('note', sa.Text(), nullable=False),
sa.Column('is_read', sa.Boolean(), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_table('faqs',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('q', sa.String(length=512), nullable=False),
sa.Column('a', sa.Text(), nullable=False),
sa.Column('order', sa.Integer(), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_table('newsletter_subscribers',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('email', sa.String(length=255), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_newsletter_subscribers_email'), 'newsletter_subscribers', ['email'], unique=True)
op.create_table('projects',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('slug', sa.String(length=255), nullable=False),
sa.Column('title', sa.String(length=255), nullable=False),
sa.Column('location', sa.String(length=255), nullable=False),
sa.Column('year', sa.String(length=64), nullable=False),
sa.Column('status', sa.Enum('done', 'progress', name='projectstatus'), nullable=False),
sa.Column('image', sa.String(length=1024), nullable=False),
sa.Column('gallery', sa.JSON(), nullable=False),
sa.Column('area', sa.String(length=128), nullable=False),
sa.Column('floors', sa.String(length=128), nullable=False),
sa.Column('units', sa.String(length=128), nullable=False),
sa.Column('client', sa.String(length=255), nullable=False),
sa.Column('summary', sa.Text(), nullable=False),
sa.Column('body', sa.JSON(), nullable=False),
sa.Column('order', sa.Integer(), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_projects_slug'), 'projects', ['slug'], unique=True)
op.create_table('services',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('title', sa.String(length=255), nullable=False),
sa.Column('desc', sa.Text(), nullable=False),
sa.Column('icon', sa.String(length=64), nullable=False),
sa.Column('order', sa.Integer(), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_table('stats',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('value', sa.Integer(), nullable=False),
sa.Column('suffix', sa.String(length=32), nullable=False),
sa.Column('label', sa.String(length=255), nullable=False),
sa.Column('order', sa.Integer(), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_table('team_members',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=255), nullable=False),
sa.Column('role', sa.String(length=255), nullable=False),
sa.Column('bio', sa.Text(), nullable=False),
sa.Column('photo', sa.String(length=1024), nullable=False),
sa.Column('order', sa.Integer(), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_table('testimonials',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=255), nullable=False),
sa.Column('role', sa.String(length=255), nullable=False),
sa.Column('quote', sa.Text(), nullable=False),
sa.Column('order', sa.Integer(), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_table('timeline_items',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('year', sa.String(length=64), nullable=False),
sa.Column('title', sa.String(length=255), nullable=False),
sa.Column('desc', sa.Text(), nullable=False),
sa.Column('image', sa.String(length=1024), nullable=False),
sa.Column('order', sa.Integer(), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_table('why_us_items',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('title', sa.String(length=255), nullable=False),
sa.Column('desc', sa.Text(), nullable=False),
sa.Column('order', sa.Integer(), nullable=False),
sa.PrimaryKeyConstraint('id')
)
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('why_us_items')
op.drop_table('timeline_items')
op.drop_table('testimonials')
op.drop_table('team_members')
op.drop_table('stats')
op.drop_table('services')
op.drop_index(op.f('ix_projects_slug'), table_name='projects')
op.drop_table('projects')
op.drop_index(op.f('ix_newsletter_subscribers_email'), table_name='newsletter_subscribers')
op.drop_table('newsletter_subscribers')
op.drop_table('faqs')
op.drop_table('contact_leads')
op.drop_table('brand')
op.drop_index(op.f('ix_articles_slug'), table_name='articles')
op.drop_table('articles')
op.drop_index(op.f('ix_admin_users_username'), table_name='admin_users')
op.drop_table('admin_users')
# ### end Alembic commands ###