style: apply black and isort formatting across entire codebase
- Standardize quote style (single to double quotes) - Reorder and group imports alphabetically - Fix line breaks and indentation for consistency - Apply PEP 8 formatting standards Also updated Makefile to exclude both venv and .venv from code quality checks. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -15,6 +15,7 @@ import sys
|
||||
from logging.config import fileConfig
|
||||
|
||||
from sqlalchemy import engine_from_config, pool
|
||||
|
||||
from alembic import context
|
||||
|
||||
# Add your project directory to the Python path
|
||||
@@ -39,13 +40,9 @@ print("=" * 70)
|
||||
# ADMIN MODELS
|
||||
# ----------------------------------------------------------------------------
|
||||
try:
|
||||
from models.database.admin import (
|
||||
AdminAuditLog,
|
||||
AdminNotification,
|
||||
AdminSetting,
|
||||
PlatformAlert,
|
||||
AdminSession
|
||||
)
|
||||
from models.database.admin import (AdminAuditLog, AdminNotification,
|
||||
AdminSession, AdminSetting,
|
||||
PlatformAlert)
|
||||
|
||||
print(" ✓ Admin models imported (5 models)")
|
||||
print(" - AdminAuditLog")
|
||||
@@ -70,7 +67,7 @@ except ImportError as e:
|
||||
# VENDOR MODELS
|
||||
# ----------------------------------------------------------------------------
|
||||
try:
|
||||
from models.database.vendor import Vendor, VendorUser, Role
|
||||
from models.database.vendor import Role, Vendor, VendorUser
|
||||
|
||||
print(" ✓ Vendor models imported (3 models)")
|
||||
print(" - Vendor")
|
||||
@@ -248,10 +245,7 @@ def run_migrations_online() -> None:
|
||||
)
|
||||
|
||||
with connectable.connect() as connection:
|
||||
context.configure(
|
||||
connection=connection,
|
||||
target_metadata=target_metadata
|
||||
)
|
||||
context.configure(connection=connection, target_metadata=target_metadata)
|
||||
|
||||
with context.begin_transaction():
|
||||
context.run_migrations()
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,59 +5,72 @@ Revises: fef1d20ce8b4
|
||||
Create Date: 2025-11-22 15:16:13.213613
|
||||
|
||||
"""
|
||||
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '72aa309d4007'
|
||||
down_revision: Union[str, None] = 'fef1d20ce8b4'
|
||||
revision: str = "72aa309d4007"
|
||||
down_revision: Union[str, None] = "fef1d20ce8b4"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('content_pages',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('vendor_id', sa.Integer(), nullable=True),
|
||||
sa.Column('slug', sa.String(length=100), nullable=False),
|
||||
sa.Column('title', sa.String(length=200), nullable=False),
|
||||
sa.Column('content', sa.Text(), nullable=False),
|
||||
sa.Column('content_format', sa.String(length=20), nullable=True),
|
||||
sa.Column('meta_description', sa.String(length=300), nullable=True),
|
||||
sa.Column('meta_keywords', sa.String(length=300), nullable=True),
|
||||
sa.Column('is_published', sa.Boolean(), nullable=False),
|
||||
sa.Column('published_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('display_order', sa.Integer(), nullable=True),
|
||||
sa.Column('show_in_footer', sa.Boolean(), nullable=True),
|
||||
sa.Column('show_in_header', sa.Boolean(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=False),
|
||||
sa.Column('created_by', sa.Integer(), nullable=True),
|
||||
sa.Column('updated_by', sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['created_by'], ['users.id'], ondelete='SET NULL'),
|
||||
sa.ForeignKeyConstraint(['updated_by'], ['users.id'], ondelete='SET NULL'),
|
||||
sa.ForeignKeyConstraint(['vendor_id'], ['vendors.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('vendor_id', 'slug', name='uq_vendor_slug')
|
||||
op.create_table(
|
||||
"content_pages",
|
||||
sa.Column("id", sa.Integer(), nullable=False),
|
||||
sa.Column("vendor_id", sa.Integer(), nullable=True),
|
||||
sa.Column("slug", sa.String(length=100), nullable=False),
|
||||
sa.Column("title", sa.String(length=200), nullable=False),
|
||||
sa.Column("content", sa.Text(), nullable=False),
|
||||
sa.Column("content_format", sa.String(length=20), nullable=True),
|
||||
sa.Column("meta_description", sa.String(length=300), nullable=True),
|
||||
sa.Column("meta_keywords", sa.String(length=300), nullable=True),
|
||||
sa.Column("is_published", sa.Boolean(), nullable=False),
|
||||
sa.Column("published_at", sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column("display_order", sa.Integer(), nullable=True),
|
||||
sa.Column("show_in_footer", sa.Boolean(), nullable=True),
|
||||
sa.Column("show_in_header", sa.Boolean(), nullable=True),
|
||||
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
|
||||
sa.Column("updated_at", sa.DateTime(timezone=True), nullable=False),
|
||||
sa.Column("created_by", sa.Integer(), nullable=True),
|
||||
sa.Column("updated_by", sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(["created_by"], ["users.id"], ondelete="SET NULL"),
|
||||
sa.ForeignKeyConstraint(["updated_by"], ["users.id"], ondelete="SET NULL"),
|
||||
sa.ForeignKeyConstraint(["vendor_id"], ["vendors.id"], ondelete="CASCADE"),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
sa.UniqueConstraint("vendor_id", "slug", name="uq_vendor_slug"),
|
||||
)
|
||||
op.create_index(
|
||||
"idx_slug_published", "content_pages", ["slug", "is_published"], unique=False
|
||||
)
|
||||
op.create_index(
|
||||
"idx_vendor_published",
|
||||
"content_pages",
|
||||
["vendor_id", "is_published"],
|
||||
unique=False,
|
||||
)
|
||||
op.create_index(op.f("ix_content_pages_id"), "content_pages", ["id"], unique=False)
|
||||
op.create_index(
|
||||
op.f("ix_content_pages_slug"), "content_pages", ["slug"], unique=False
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_content_pages_vendor_id"), "content_pages", ["vendor_id"], unique=False
|
||||
)
|
||||
op.create_index('idx_slug_published', 'content_pages', ['slug', 'is_published'], unique=False)
|
||||
op.create_index('idx_vendor_published', 'content_pages', ['vendor_id', 'is_published'], unique=False)
|
||||
op.create_index(op.f('ix_content_pages_id'), 'content_pages', ['id'], unique=False)
|
||||
op.create_index(op.f('ix_content_pages_slug'), 'content_pages', ['slug'], unique=False)
|
||||
op.create_index(op.f('ix_content_pages_vendor_id'), 'content_pages', ['vendor_id'], unique=False)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f('ix_content_pages_vendor_id'), table_name='content_pages')
|
||||
op.drop_index(op.f('ix_content_pages_slug'), table_name='content_pages')
|
||||
op.drop_index(op.f('ix_content_pages_id'), table_name='content_pages')
|
||||
op.drop_index('idx_vendor_published', table_name='content_pages')
|
||||
op.drop_index('idx_slug_published', table_name='content_pages')
|
||||
op.drop_table('content_pages')
|
||||
op.drop_index(op.f("ix_content_pages_vendor_id"), table_name="content_pages")
|
||||
op.drop_index(op.f("ix_content_pages_slug"), table_name="content_pages")
|
||||
op.drop_index(op.f("ix_content_pages_id"), table_name="content_pages")
|
||||
op.drop_index("idx_vendor_published", table_name="content_pages")
|
||||
op.drop_index("idx_slug_published", table_name="content_pages")
|
||||
op.drop_table("content_pages")
|
||||
# ### end Alembic commands ###
|
||||
|
||||
@@ -5,15 +5,17 @@ Revises: a2064e1dfcd4
|
||||
Create Date: 2025-11-28 09:21:16.545203
|
||||
|
||||
"""
|
||||
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '7a7ce92593d5'
|
||||
down_revision: Union[str, None] = 'a2064e1dfcd4'
|
||||
revision: str = "7a7ce92593d5"
|
||||
down_revision: Union[str, None] = "a2064e1dfcd4"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
@@ -21,127 +23,269 @@ depends_on: Union[str, Sequence[str], None] = None
|
||||
def upgrade() -> None:
|
||||
# Create architecture_scans table
|
||||
op.create_table(
|
||||
'architecture_scans',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('timestamp', sa.DateTime(timezone=True), server_default=sa.text("(datetime('now'))"), nullable=False),
|
||||
sa.Column('total_files', sa.Integer(), nullable=True),
|
||||
sa.Column('total_violations', sa.Integer(), nullable=True),
|
||||
sa.Column('errors', sa.Integer(), nullable=True),
|
||||
sa.Column('warnings', sa.Integer(), nullable=True),
|
||||
sa.Column('duration_seconds', sa.Float(), nullable=True),
|
||||
sa.Column('triggered_by', sa.String(length=100), nullable=True),
|
||||
sa.Column('git_commit_hash', sa.String(length=40), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
"architecture_scans",
|
||||
sa.Column("id", sa.Integer(), nullable=False),
|
||||
sa.Column(
|
||||
"timestamp",
|
||||
sa.DateTime(timezone=True),
|
||||
server_default=sa.text("(datetime('now'))"),
|
||||
nullable=False,
|
||||
),
|
||||
sa.Column("total_files", sa.Integer(), nullable=True),
|
||||
sa.Column("total_violations", sa.Integer(), nullable=True),
|
||||
sa.Column("errors", sa.Integer(), nullable=True),
|
||||
sa.Column("warnings", sa.Integer(), nullable=True),
|
||||
sa.Column("duration_seconds", sa.Float(), nullable=True),
|
||||
sa.Column("triggered_by", sa.String(length=100), nullable=True),
|
||||
sa.Column("git_commit_hash", sa.String(length=40), nullable=True),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_architecture_scans_id"), "architecture_scans", ["id"], unique=False
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_architecture_scans_timestamp"),
|
||||
"architecture_scans",
|
||||
["timestamp"],
|
||||
unique=False,
|
||||
)
|
||||
op.create_index(op.f('ix_architecture_scans_id'), 'architecture_scans', ['id'], unique=False)
|
||||
op.create_index(op.f('ix_architecture_scans_timestamp'), 'architecture_scans', ['timestamp'], unique=False)
|
||||
|
||||
# Create architecture_rules table
|
||||
op.create_table(
|
||||
'architecture_rules',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('rule_id', sa.String(length=20), nullable=False),
|
||||
sa.Column('category', sa.String(length=50), nullable=False),
|
||||
sa.Column('name', sa.String(length=200), nullable=False),
|
||||
sa.Column('description', sa.Text(), nullable=True),
|
||||
sa.Column('severity', sa.String(length=10), nullable=False),
|
||||
sa.Column('enabled', sa.Boolean(), nullable=False, server_default='1'),
|
||||
sa.Column('custom_config', sa.JSON(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text("(datetime('now'))"), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text("(datetime('now'))"), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('rule_id')
|
||||
"architecture_rules",
|
||||
sa.Column("id", sa.Integer(), nullable=False),
|
||||
sa.Column("rule_id", sa.String(length=20), nullable=False),
|
||||
sa.Column("category", sa.String(length=50), nullable=False),
|
||||
sa.Column("name", sa.String(length=200), nullable=False),
|
||||
sa.Column("description", sa.Text(), nullable=True),
|
||||
sa.Column("severity", sa.String(length=10), nullable=False),
|
||||
sa.Column("enabled", sa.Boolean(), nullable=False, server_default="1"),
|
||||
sa.Column("custom_config", sa.JSON(), nullable=True),
|
||||
sa.Column(
|
||||
"created_at",
|
||||
sa.DateTime(timezone=True),
|
||||
server_default=sa.text("(datetime('now'))"),
|
||||
nullable=False,
|
||||
),
|
||||
sa.Column(
|
||||
"updated_at",
|
||||
sa.DateTime(timezone=True),
|
||||
server_default=sa.text("(datetime('now'))"),
|
||||
nullable=False,
|
||||
),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
sa.UniqueConstraint("rule_id"),
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_architecture_rules_id"), "architecture_rules", ["id"], unique=False
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_architecture_rules_rule_id"),
|
||||
"architecture_rules",
|
||||
["rule_id"],
|
||||
unique=True,
|
||||
)
|
||||
op.create_index(op.f('ix_architecture_rules_id'), 'architecture_rules', ['id'], unique=False)
|
||||
op.create_index(op.f('ix_architecture_rules_rule_id'), 'architecture_rules', ['rule_id'], unique=True)
|
||||
|
||||
# Create architecture_violations table
|
||||
op.create_table(
|
||||
'architecture_violations',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('scan_id', sa.Integer(), nullable=False),
|
||||
sa.Column('rule_id', sa.String(length=20), nullable=False),
|
||||
sa.Column('rule_name', sa.String(length=200), nullable=False),
|
||||
sa.Column('severity', sa.String(length=10), nullable=False),
|
||||
sa.Column('file_path', sa.String(length=500), nullable=False),
|
||||
sa.Column('line_number', sa.Integer(), nullable=False),
|
||||
sa.Column('message', sa.Text(), nullable=False),
|
||||
sa.Column('context', sa.Text(), nullable=True),
|
||||
sa.Column('suggestion', sa.Text(), nullable=True),
|
||||
sa.Column('status', sa.String(length=20), server_default='open', nullable=True),
|
||||
sa.Column('assigned_to', sa.Integer(), nullable=True),
|
||||
sa.Column('resolved_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('resolved_by', sa.Integer(), nullable=True),
|
||||
sa.Column('resolution_note', sa.Text(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text("(datetime('now'))"), nullable=False),
|
||||
sa.ForeignKeyConstraint(['assigned_to'], ['users.id'], ),
|
||||
sa.ForeignKeyConstraint(['resolved_by'], ['users.id'], ),
|
||||
sa.ForeignKeyConstraint(['scan_id'], ['architecture_scans.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
"architecture_violations",
|
||||
sa.Column("id", sa.Integer(), nullable=False),
|
||||
sa.Column("scan_id", sa.Integer(), nullable=False),
|
||||
sa.Column("rule_id", sa.String(length=20), nullable=False),
|
||||
sa.Column("rule_name", sa.String(length=200), nullable=False),
|
||||
sa.Column("severity", sa.String(length=10), nullable=False),
|
||||
sa.Column("file_path", sa.String(length=500), nullable=False),
|
||||
sa.Column("line_number", sa.Integer(), nullable=False),
|
||||
sa.Column("message", sa.Text(), nullable=False),
|
||||
sa.Column("context", sa.Text(), nullable=True),
|
||||
sa.Column("suggestion", sa.Text(), nullable=True),
|
||||
sa.Column("status", sa.String(length=20), server_default="open", nullable=True),
|
||||
sa.Column("assigned_to", sa.Integer(), nullable=True),
|
||||
sa.Column("resolved_at", sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column("resolved_by", sa.Integer(), nullable=True),
|
||||
sa.Column("resolution_note", sa.Text(), nullable=True),
|
||||
sa.Column(
|
||||
"created_at",
|
||||
sa.DateTime(timezone=True),
|
||||
server_default=sa.text("(datetime('now'))"),
|
||||
nullable=False,
|
||||
),
|
||||
sa.ForeignKeyConstraint(
|
||||
["assigned_to"],
|
||||
["users.id"],
|
||||
),
|
||||
sa.ForeignKeyConstraint(
|
||||
["resolved_by"],
|
||||
["users.id"],
|
||||
),
|
||||
sa.ForeignKeyConstraint(
|
||||
["scan_id"],
|
||||
["architecture_scans.id"],
|
||||
),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_architecture_violations_file_path"),
|
||||
"architecture_violations",
|
||||
["file_path"],
|
||||
unique=False,
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_architecture_violations_id"),
|
||||
"architecture_violations",
|
||||
["id"],
|
||||
unique=False,
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_architecture_violations_rule_id"),
|
||||
"architecture_violations",
|
||||
["rule_id"],
|
||||
unique=False,
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_architecture_violations_scan_id"),
|
||||
"architecture_violations",
|
||||
["scan_id"],
|
||||
unique=False,
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_architecture_violations_severity"),
|
||||
"architecture_violations",
|
||||
["severity"],
|
||||
unique=False,
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_architecture_violations_status"),
|
||||
"architecture_violations",
|
||||
["status"],
|
||||
unique=False,
|
||||
)
|
||||
op.create_index(op.f('ix_architecture_violations_file_path'), 'architecture_violations', ['file_path'], unique=False)
|
||||
op.create_index(op.f('ix_architecture_violations_id'), 'architecture_violations', ['id'], unique=False)
|
||||
op.create_index(op.f('ix_architecture_violations_rule_id'), 'architecture_violations', ['rule_id'], unique=False)
|
||||
op.create_index(op.f('ix_architecture_violations_scan_id'), 'architecture_violations', ['scan_id'], unique=False)
|
||||
op.create_index(op.f('ix_architecture_violations_severity'), 'architecture_violations', ['severity'], unique=False)
|
||||
op.create_index(op.f('ix_architecture_violations_status'), 'architecture_violations', ['status'], unique=False)
|
||||
|
||||
# Create violation_assignments table
|
||||
op.create_table(
|
||||
'violation_assignments',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('violation_id', sa.Integer(), nullable=False),
|
||||
sa.Column('user_id', sa.Integer(), nullable=False),
|
||||
sa.Column('assigned_at', sa.DateTime(timezone=True), server_default=sa.text("(datetime('now'))"), nullable=False),
|
||||
sa.Column('assigned_by', sa.Integer(), nullable=True),
|
||||
sa.Column('due_date', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('priority', sa.String(length=10), server_default='medium', nullable=True),
|
||||
sa.ForeignKeyConstraint(['assigned_by'], ['users.id'], ),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
||||
sa.ForeignKeyConstraint(['violation_id'], ['architecture_violations.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
"violation_assignments",
|
||||
sa.Column("id", sa.Integer(), nullable=False),
|
||||
sa.Column("violation_id", sa.Integer(), nullable=False),
|
||||
sa.Column("user_id", sa.Integer(), nullable=False),
|
||||
sa.Column(
|
||||
"assigned_at",
|
||||
sa.DateTime(timezone=True),
|
||||
server_default=sa.text("(datetime('now'))"),
|
||||
nullable=False,
|
||||
),
|
||||
sa.Column("assigned_by", sa.Integer(), nullable=True),
|
||||
sa.Column("due_date", sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column(
|
||||
"priority", sa.String(length=10), server_default="medium", nullable=True
|
||||
),
|
||||
sa.ForeignKeyConstraint(
|
||||
["assigned_by"],
|
||||
["users.id"],
|
||||
),
|
||||
sa.ForeignKeyConstraint(
|
||||
["user_id"],
|
||||
["users.id"],
|
||||
),
|
||||
sa.ForeignKeyConstraint(
|
||||
["violation_id"],
|
||||
["architecture_violations.id"],
|
||||
),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_violation_assignments_id"),
|
||||
"violation_assignments",
|
||||
["id"],
|
||||
unique=False,
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_violation_assignments_violation_id"),
|
||||
"violation_assignments",
|
||||
["violation_id"],
|
||||
unique=False,
|
||||
)
|
||||
op.create_index(op.f('ix_violation_assignments_id'), 'violation_assignments', ['id'], unique=False)
|
||||
op.create_index(op.f('ix_violation_assignments_violation_id'), 'violation_assignments', ['violation_id'], unique=False)
|
||||
|
||||
# Create violation_comments table
|
||||
op.create_table(
|
||||
'violation_comments',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('violation_id', sa.Integer(), nullable=False),
|
||||
sa.Column('user_id', sa.Integer(), nullable=False),
|
||||
sa.Column('comment', sa.Text(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text("(datetime('now'))"), nullable=False),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
||||
sa.ForeignKeyConstraint(['violation_id'], ['architecture_violations.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
"violation_comments",
|
||||
sa.Column("id", sa.Integer(), nullable=False),
|
||||
sa.Column("violation_id", sa.Integer(), nullable=False),
|
||||
sa.Column("user_id", sa.Integer(), nullable=False),
|
||||
sa.Column("comment", sa.Text(), nullable=False),
|
||||
sa.Column(
|
||||
"created_at",
|
||||
sa.DateTime(timezone=True),
|
||||
server_default=sa.text("(datetime('now'))"),
|
||||
nullable=False,
|
||||
),
|
||||
sa.ForeignKeyConstraint(
|
||||
["user_id"],
|
||||
["users.id"],
|
||||
),
|
||||
sa.ForeignKeyConstraint(
|
||||
["violation_id"],
|
||||
["architecture_violations.id"],
|
||||
),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_violation_comments_id"), "violation_comments", ["id"], unique=False
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_violation_comments_violation_id"),
|
||||
"violation_comments",
|
||||
["violation_id"],
|
||||
unique=False,
|
||||
)
|
||||
op.create_index(op.f('ix_violation_comments_id'), 'violation_comments', ['id'], unique=False)
|
||||
op.create_index(op.f('ix_violation_comments_violation_id'), 'violation_comments', ['violation_id'], unique=False)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# Drop tables in reverse order (to respect foreign key constraints)
|
||||
op.drop_index(op.f('ix_violation_comments_violation_id'), table_name='violation_comments')
|
||||
op.drop_index(op.f('ix_violation_comments_id'), table_name='violation_comments')
|
||||
op.drop_table('violation_comments')
|
||||
op.drop_index(
|
||||
op.f("ix_violation_comments_violation_id"), table_name="violation_comments"
|
||||
)
|
||||
op.drop_index(op.f("ix_violation_comments_id"), table_name="violation_comments")
|
||||
op.drop_table("violation_comments")
|
||||
|
||||
op.drop_index(op.f('ix_violation_assignments_violation_id'), table_name='violation_assignments')
|
||||
op.drop_index(op.f('ix_violation_assignments_id'), table_name='violation_assignments')
|
||||
op.drop_table('violation_assignments')
|
||||
op.drop_index(
|
||||
op.f("ix_violation_assignments_violation_id"),
|
||||
table_name="violation_assignments",
|
||||
)
|
||||
op.drop_index(
|
||||
op.f("ix_violation_assignments_id"), table_name="violation_assignments"
|
||||
)
|
||||
op.drop_table("violation_assignments")
|
||||
|
||||
op.drop_index(op.f('ix_architecture_violations_status'), table_name='architecture_violations')
|
||||
op.drop_index(op.f('ix_architecture_violations_severity'), table_name='architecture_violations')
|
||||
op.drop_index(op.f('ix_architecture_violations_scan_id'), table_name='architecture_violations')
|
||||
op.drop_index(op.f('ix_architecture_violations_rule_id'), table_name='architecture_violations')
|
||||
op.drop_index(op.f('ix_architecture_violations_id'), table_name='architecture_violations')
|
||||
op.drop_index(op.f('ix_architecture_violations_file_path'), table_name='architecture_violations')
|
||||
op.drop_table('architecture_violations')
|
||||
op.drop_index(
|
||||
op.f("ix_architecture_violations_status"), table_name="architecture_violations"
|
||||
)
|
||||
op.drop_index(
|
||||
op.f("ix_architecture_violations_severity"),
|
||||
table_name="architecture_violations",
|
||||
)
|
||||
op.drop_index(
|
||||
op.f("ix_architecture_violations_scan_id"), table_name="architecture_violations"
|
||||
)
|
||||
op.drop_index(
|
||||
op.f("ix_architecture_violations_rule_id"), table_name="architecture_violations"
|
||||
)
|
||||
op.drop_index(
|
||||
op.f("ix_architecture_violations_id"), table_name="architecture_violations"
|
||||
)
|
||||
op.drop_index(
|
||||
op.f("ix_architecture_violations_file_path"),
|
||||
table_name="architecture_violations",
|
||||
)
|
||||
op.drop_table("architecture_violations")
|
||||
|
||||
op.drop_index(op.f('ix_architecture_rules_rule_id'), table_name='architecture_rules')
|
||||
op.drop_index(op.f('ix_architecture_rules_id'), table_name='architecture_rules')
|
||||
op.drop_table('architecture_rules')
|
||||
op.drop_index(
|
||||
op.f("ix_architecture_rules_rule_id"), table_name="architecture_rules"
|
||||
)
|
||||
op.drop_index(op.f("ix_architecture_rules_id"), table_name="architecture_rules")
|
||||
op.drop_table("architecture_rules")
|
||||
|
||||
op.drop_index(op.f('ix_architecture_scans_timestamp'), table_name='architecture_scans')
|
||||
op.drop_index(op.f('ix_architecture_scans_id'), table_name='architecture_scans')
|
||||
op.drop_table('architecture_scans')
|
||||
op.drop_index(
|
||||
op.f("ix_architecture_scans_timestamp"), table_name="architecture_scans"
|
||||
)
|
||||
op.drop_index(op.f("ix_architecture_scans_id"), table_name="architecture_scans")
|
||||
op.drop_table("architecture_scans")
|
||||
|
||||
@@ -5,15 +5,16 @@ Revises: f68d8da5315a
|
||||
Create Date: 2025-11-23 19:52:40.509538
|
||||
|
||||
"""
|
||||
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'a2064e1dfcd4'
|
||||
down_revision: Union[str, None] = 'f68d8da5315a'
|
||||
revision: str = "a2064e1dfcd4"
|
||||
down_revision: Union[str, None] = "f68d8da5315a"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
@@ -21,34 +22,46 @@ depends_on: Union[str, Sequence[str], None] = None
|
||||
def upgrade() -> None:
|
||||
# Create cart_items table
|
||||
op.create_table(
|
||||
'cart_items',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('vendor_id', sa.Integer(), nullable=False),
|
||||
sa.Column('product_id', sa.Integer(), nullable=False),
|
||||
sa.Column('session_id', sa.String(length=255), nullable=False),
|
||||
sa.Column('quantity', sa.Integer(), nullable=False),
|
||||
sa.Column('price_at_add', sa.Float(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['product_id'], ['products.id'], ),
|
||||
sa.ForeignKeyConstraint(['vendor_id'], ['vendors.id'], ),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('vendor_id', 'session_id', 'product_id', name='uq_cart_item')
|
||||
"cart_items",
|
||||
sa.Column("id", sa.Integer(), nullable=False),
|
||||
sa.Column("vendor_id", sa.Integer(), nullable=False),
|
||||
sa.Column("product_id", sa.Integer(), nullable=False),
|
||||
sa.Column("session_id", sa.String(length=255), nullable=False),
|
||||
sa.Column("quantity", sa.Integer(), nullable=False),
|
||||
sa.Column("price_at_add", sa.Float(), nullable=False),
|
||||
sa.Column("created_at", sa.DateTime(), nullable=True),
|
||||
sa.Column("updated_at", sa.DateTime(), nullable=True),
|
||||
sa.ForeignKeyConstraint(
|
||||
["product_id"],
|
||||
["products.id"],
|
||||
),
|
||||
sa.ForeignKeyConstraint(
|
||||
["vendor_id"],
|
||||
["vendors.id"],
|
||||
),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
sa.UniqueConstraint(
|
||||
"vendor_id", "session_id", "product_id", name="uq_cart_item"
|
||||
),
|
||||
)
|
||||
|
||||
# Create indexes
|
||||
op.create_index('idx_cart_session', 'cart_items', ['vendor_id', 'session_id'], unique=False)
|
||||
op.create_index('idx_cart_created', 'cart_items', ['created_at'], unique=False)
|
||||
op.create_index(op.f('ix_cart_items_id'), 'cart_items', ['id'], unique=False)
|
||||
op.create_index(op.f('ix_cart_items_session_id'), 'cart_items', ['session_id'], unique=False)
|
||||
op.create_index(
|
||||
"idx_cart_session", "cart_items", ["vendor_id", "session_id"], unique=False
|
||||
)
|
||||
op.create_index("idx_cart_created", "cart_items", ["created_at"], unique=False)
|
||||
op.create_index(op.f("ix_cart_items_id"), "cart_items", ["id"], unique=False)
|
||||
op.create_index(
|
||||
op.f("ix_cart_items_session_id"), "cart_items", ["session_id"], unique=False
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# Drop indexes
|
||||
op.drop_index(op.f('ix_cart_items_session_id'), table_name='cart_items')
|
||||
op.drop_index(op.f('ix_cart_items_id'), table_name='cart_items')
|
||||
op.drop_index('idx_cart_created', table_name='cart_items')
|
||||
op.drop_index('idx_cart_session', table_name='cart_items')
|
||||
op.drop_index(op.f("ix_cart_items_session_id"), table_name="cart_items")
|
||||
op.drop_index(op.f("ix_cart_items_id"), table_name="cart_items")
|
||||
op.drop_index("idx_cart_created", table_name="cart_items")
|
||||
op.drop_index("idx_cart_session", table_name="cart_items")
|
||||
|
||||
# Drop table
|
||||
op.drop_table('cart_items')
|
||||
op.drop_table("cart_items")
|
||||
|
||||
@@ -5,24 +5,30 @@ Revises: 72aa309d4007
|
||||
Create Date: 2025-11-22 23:51:40.694983
|
||||
|
||||
"""
|
||||
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'f68d8da5315a'
|
||||
down_revision: Union[str, None] = '72aa309d4007'
|
||||
revision: str = "f68d8da5315a"
|
||||
down_revision: Union[str, None] = "72aa309d4007"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# Add template column to content_pages table
|
||||
op.add_column('content_pages', sa.Column('template', sa.String(length=50), nullable=False, server_default='default'))
|
||||
op.add_column(
|
||||
"content_pages",
|
||||
sa.Column(
|
||||
"template", sa.String(length=50), nullable=False, server_default="default"
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# Remove template column from content_pages table
|
||||
op.drop_column('content_pages', 'template')
|
||||
op.drop_column("content_pages", "template")
|
||||
|
||||
@@ -6,15 +6,16 @@ Create Date: 2025-11-13 16:51:25.010057
|
||||
|
||||
SQLite-compatible version
|
||||
"""
|
||||
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'fa7d4d10e358'
|
||||
down_revision: Union[str, None] = '4951b2e50581'
|
||||
revision: str = "fa7d4d10e358"
|
||||
down_revision: Union[str, None] = "4951b2e50581"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
@@ -28,9 +29,14 @@ def upgrade():
|
||||
# ========================================================================
|
||||
# User table changes
|
||||
# ========================================================================
|
||||
with op.batch_alter_table('users', schema=None) as batch_op:
|
||||
with op.batch_alter_table("users", schema=None) as batch_op:
|
||||
batch_op.add_column(
|
||||
sa.Column('is_email_verified', sa.Boolean(), nullable=False, server_default='false')
|
||||
sa.Column(
|
||||
"is_email_verified",
|
||||
sa.Boolean(),
|
||||
nullable=False,
|
||||
server_default="false",
|
||||
)
|
||||
)
|
||||
|
||||
# Set existing active users as verified
|
||||
@@ -39,68 +45,65 @@ def upgrade():
|
||||
# ========================================================================
|
||||
# VendorUser table changes (requires table recreation for SQLite)
|
||||
# ========================================================================
|
||||
with op.batch_alter_table('vendor_users', schema=None) as batch_op:
|
||||
with op.batch_alter_table("vendor_users", schema=None) as batch_op:
|
||||
# Add new columns
|
||||
batch_op.add_column(
|
||||
sa.Column('user_type', sa.String(length=20), nullable=False, server_default='member')
|
||||
sa.Column(
|
||||
"user_type",
|
||||
sa.String(length=20),
|
||||
nullable=False,
|
||||
server_default="member",
|
||||
)
|
||||
)
|
||||
batch_op.add_column(
|
||||
sa.Column('invitation_token', sa.String(length=100), nullable=True)
|
||||
sa.Column("invitation_token", sa.String(length=100), nullable=True)
|
||||
)
|
||||
batch_op.add_column(
|
||||
sa.Column('invitation_sent_at', sa.DateTime(), nullable=True)
|
||||
sa.Column("invitation_sent_at", sa.DateTime(), nullable=True)
|
||||
)
|
||||
batch_op.add_column(
|
||||
sa.Column('invitation_accepted_at', sa.DateTime(), nullable=True)
|
||||
sa.Column("invitation_accepted_at", sa.DateTime(), nullable=True)
|
||||
)
|
||||
|
||||
# Create index on invitation_token
|
||||
batch_op.create_index(
|
||||
'idx_vendor_users_invitation_token',
|
||||
['invitation_token']
|
||||
)
|
||||
batch_op.create_index("idx_vendor_users_invitation_token", ["invitation_token"])
|
||||
|
||||
# Modify role_id to be nullable (this recreates the table in SQLite)
|
||||
batch_op.alter_column(
|
||||
'role_id',
|
||||
existing_type=sa.Integer(),
|
||||
nullable=True
|
||||
)
|
||||
batch_op.alter_column("role_id", existing_type=sa.Integer(), nullable=True)
|
||||
|
||||
# Change is_active default (this recreates the table in SQLite)
|
||||
batch_op.alter_column(
|
||||
'is_active',
|
||||
existing_type=sa.Boolean(),
|
||||
server_default='false'
|
||||
"is_active", existing_type=sa.Boolean(), server_default="false"
|
||||
)
|
||||
|
||||
# Set owners correctly (after table modifications)
|
||||
# SQLite-compatible UPDATE with subquery
|
||||
op.execute("""
|
||||
op.execute(
|
||||
"""
|
||||
UPDATE vendor_users
|
||||
SET user_type = 'owner'
|
||||
WHERE (vendor_id, user_id) IN (
|
||||
SELECT id, owner_user_id
|
||||
FROM vendors
|
||||
)
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
# Set existing owners as active
|
||||
op.execute("""
|
||||
op.execute(
|
||||
"""
|
||||
UPDATE vendor_users
|
||||
SET is_active = TRUE
|
||||
WHERE user_type = 'owner'
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
# ========================================================================
|
||||
# Role table changes
|
||||
# ========================================================================
|
||||
with op.batch_alter_table('roles', schema=None) as batch_op:
|
||||
with op.batch_alter_table("roles", schema=None) as batch_op:
|
||||
# Create index on vendor_id and name
|
||||
batch_op.create_index(
|
||||
'idx_roles_vendor_name',
|
||||
['vendor_id', 'name']
|
||||
)
|
||||
batch_op.create_index("idx_roles_vendor_name", ["vendor_id", "name"])
|
||||
|
||||
# Note: JSONB conversion only for PostgreSQL
|
||||
# SQLite stores JSON as TEXT by default, no conversion needed
|
||||
@@ -115,37 +118,31 @@ def downgrade():
|
||||
# ========================================================================
|
||||
# Role table changes
|
||||
# ========================================================================
|
||||
with op.batch_alter_table('roles', schema=None) as batch_op:
|
||||
batch_op.drop_index('idx_roles_vendor_name')
|
||||
with op.batch_alter_table("roles", schema=None) as batch_op:
|
||||
batch_op.drop_index("idx_roles_vendor_name")
|
||||
|
||||
# ========================================================================
|
||||
# VendorUser table changes
|
||||
# ========================================================================
|
||||
with op.batch_alter_table('vendor_users', schema=None) as batch_op:
|
||||
with op.batch_alter_table("vendor_users", schema=None) as batch_op:
|
||||
# Revert is_active default
|
||||
batch_op.alter_column(
|
||||
'is_active',
|
||||
existing_type=sa.Boolean(),
|
||||
server_default='true'
|
||||
"is_active", existing_type=sa.Boolean(), server_default="true"
|
||||
)
|
||||
|
||||
# Revert role_id to NOT NULL
|
||||
# Note: This might fail if there are NULL values
|
||||
batch_op.alter_column(
|
||||
'role_id',
|
||||
existing_type=sa.Integer(),
|
||||
nullable=False
|
||||
)
|
||||
batch_op.alter_column("role_id", existing_type=sa.Integer(), nullable=False)
|
||||
|
||||
# Drop indexes and columns
|
||||
batch_op.drop_index('idx_vendor_users_invitation_token')
|
||||
batch_op.drop_column('invitation_accepted_at')
|
||||
batch_op.drop_column('invitation_sent_at')
|
||||
batch_op.drop_column('invitation_token')
|
||||
batch_op.drop_column('user_type')
|
||||
batch_op.drop_index("idx_vendor_users_invitation_token")
|
||||
batch_op.drop_column("invitation_accepted_at")
|
||||
batch_op.drop_column("invitation_sent_at")
|
||||
batch_op.drop_column("invitation_token")
|
||||
batch_op.drop_column("user_type")
|
||||
|
||||
# ========================================================================
|
||||
# User table changes
|
||||
# ========================================================================
|
||||
with op.batch_alter_table('users', schema=None) as batch_op:
|
||||
batch_op.drop_column('is_email_verified')
|
||||
with op.batch_alter_table("users", schema=None) as batch_op:
|
||||
batch_op.drop_column("is_email_verified")
|
||||
|
||||
@@ -5,30 +5,43 @@ Revises: fa7d4d10e358
|
||||
Create Date: 2025-11-22 13:41:18.069674
|
||||
|
||||
"""
|
||||
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'fef1d20ce8b4'
|
||||
down_revision: Union[str, None] = 'fa7d4d10e358'
|
||||
revision: str = "fef1d20ce8b4"
|
||||
down_revision: Union[str, None] = "fa7d4d10e358"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index('idx_roles_vendor_name', table_name='roles')
|
||||
op.drop_index('idx_vendor_users_invitation_token', table_name='vendor_users')
|
||||
op.create_index(op.f('ix_vendor_users_invitation_token'), 'vendor_users', ['invitation_token'], unique=False)
|
||||
op.drop_index("idx_roles_vendor_name", table_name="roles")
|
||||
op.drop_index("idx_vendor_users_invitation_token", table_name="vendor_users")
|
||||
op.create_index(
|
||||
op.f("ix_vendor_users_invitation_token"),
|
||||
"vendor_users",
|
||||
["invitation_token"],
|
||||
unique=False,
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f('ix_vendor_users_invitation_token'), table_name='vendor_users')
|
||||
op.create_index('idx_vendor_users_invitation_token', 'vendor_users', ['invitation_token'], unique=False)
|
||||
op.create_index('idx_roles_vendor_name', 'roles', ['vendor_id', 'name'], unique=False)
|
||||
op.drop_index(op.f("ix_vendor_users_invitation_token"), table_name="vendor_users")
|
||||
op.create_index(
|
||||
"idx_vendor_users_invitation_token",
|
||||
"vendor_users",
|
||||
["invitation_token"],
|
||||
unique=False,
|
||||
)
|
||||
op.create_index(
|
||||
"idx_roles_vendor_name", "roles", ["vendor_id", "name"], unique=False
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
Reference in New Issue
Block a user