basic profile
This commit is contained in:
1
packages/backend/alembic/README
Normal file
1
packages/backend/alembic/README
Normal file
@@ -0,0 +1 @@
|
||||
Generic single-database configuration.
|
||||
BIN
packages/backend/alembic/__pycache__/env.cpython-311.pyc
Normal file
BIN
packages/backend/alembic/__pycache__/env.cpython-311.pyc
Normal file
Binary file not shown.
45
packages/backend/alembic/env.py
Normal file
45
packages/backend/alembic/env.py
Normal file
@@ -0,0 +1,45 @@
|
||||
# packages/backend/alembic/env.py
|
||||
|
||||
import os
|
||||
import sys
|
||||
from logging.config import fileConfig
|
||||
|
||||
from dotenv import load_dotenv # <--- 1. AGGIUNGI QUESTO IMPORT
|
||||
|
||||
from sqlalchemy import engine_from_config
|
||||
from sqlalchemy import pool
|
||||
|
||||
from alembic import context
|
||||
|
||||
# Aggiungi la root del progetto (/app) al percorso di ricerca di Python
|
||||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
|
||||
|
||||
# Aggiungi l'import del tuo modello specifico sotto l'import di Base
|
||||
from app.models import Base, Celebrity
|
||||
|
||||
# this is the Alembic Config object, which provides
|
||||
# access to the values within the .ini file in use.
|
||||
config = context.config
|
||||
|
||||
# === 2. AGGIUNGI QUESTA SEZIONE PER CARICARE LA VARIABILE D'AMBIENTE ===
|
||||
# Carica il file .env che si trova nella root del progetto (/app)
|
||||
# Dato che lo script è in /app/alembic, dobbiamo risalire di un livello
|
||||
dotenv_path = os.path.join(os.path.dirname(__file__), '..', '.env')
|
||||
load_dotenv(dotenv_path=dotenv_path)
|
||||
|
||||
# Imposta programmaticamente l'URL del database nell'oggetto di configurazione di Alembic
|
||||
config.set_main_option('sqlalchemy.url', os.getenv('DATABASE_URL'))
|
||||
# === FINE DELLA SEZIONE DA AGGIUNGERE ===
|
||||
|
||||
# Interpret the config file for Python logging.
|
||||
# This line sets up loggers basically.
|
||||
if config.config_file_name is not None:
|
||||
fileConfig(config.config_file_name)
|
||||
|
||||
# add your model's MetaData object here
|
||||
# for 'autogenerate' support
|
||||
# from myapp import mymodel
|
||||
# target_metadata = mymodel.Base.metadata
|
||||
target_metadata = Base.metadata
|
||||
|
||||
# ... il resto del file rimane invariato ...
|
||||
28
packages/backend/alembic/script.py.mako
Normal file
28
packages/backend/alembic/script.py.mako
Normal file
@@ -0,0 +1,28 @@
|
||||
"""${message}
|
||||
|
||||
Revision ID: ${up_revision}
|
||||
Revises: ${down_revision | comma,n}
|
||||
Create Date: ${create_date}
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
${imports if imports else ""}
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = ${repr(up_revision)}
|
||||
down_revision: Union[str, Sequence[str], None] = ${repr(down_revision)}
|
||||
branch_labels: Union[str, Sequence[str], None] = ${repr(branch_labels)}
|
||||
depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
${upgrades if upgrades else "pass"}
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
${downgrades if downgrades else "pass"}
|
||||
@@ -0,0 +1,28 @@
|
||||
"""Initial migration with celebrities table
|
||||
|
||||
Revision ID: 23353f53a7cf
|
||||
Revises:
|
||||
Create Date: 2025-10-10 17:00:56.622311
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '23353f53a7cf'
|
||||
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."""
|
||||
pass
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
pass
|
||||
Binary file not shown.
Reference in New Issue
Block a user