Fix issues
This commit is contained in:
@@ -2,7 +2,6 @@ apiVersion: v1
|
|||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
metadata:
|
metadata:
|
||||||
name: bakery-config
|
name: bakery-config
|
||||||
namespace: bakery-ia
|
|
||||||
labels:
|
labels:
|
||||||
app.kubernetes.io/name: bakery-ia
|
app.kubernetes.io/name: bakery-ia
|
||||||
app.kubernetes.io/component: config
|
app.kubernetes.io/component: config
|
||||||
@@ -22,7 +21,7 @@ data:
|
|||||||
BUILD_DATE: "2024-01-20T10:00:00Z"
|
BUILD_DATE: "2024-01-20T10:00:00Z"
|
||||||
VCS_REF: "latest"
|
VCS_REF: "latest"
|
||||||
IMAGE_TAG: "latest"
|
IMAGE_TAG: "latest"
|
||||||
DOMAIN: "localhost"
|
DOMAIN: "bakery.yourdomain.com"
|
||||||
AUTO_RELOAD: "false"
|
AUTO_RELOAD: "false"
|
||||||
PROFILING_ENABLED: "false"
|
PROFILING_ENABLED: "false"
|
||||||
MOCK_EXTERNAL_APIS: "false"
|
MOCK_EXTERNAL_APIS: "false"
|
||||||
@@ -109,7 +108,7 @@ data:
|
|||||||
# ================================================================
|
# ================================================================
|
||||||
# CORS & API CONFIGURATION
|
# CORS & API CONFIGURATION
|
||||||
# ================================================================
|
# ================================================================
|
||||||
CORS_ORIGINS: "http://frontend-service:3000,http://localhost:3000,http://bakery-ia.local,https://bakery.yourdomain.com,http://localhost"
|
CORS_ORIGINS: "https://bakery.yourdomain.com,http://frontend-service:3000"
|
||||||
CORS_ALLOW_CREDENTIALS: "true"
|
CORS_ALLOW_CREDENTIALS: "true"
|
||||||
RATE_LIMIT_ENABLED: "true"
|
RATE_LIMIT_ENABLED: "true"
|
||||||
RATE_LIMIT_REQUESTS: "100"
|
RATE_LIMIT_REQUESTS: "100"
|
||||||
@@ -136,11 +135,11 @@ data:
|
|||||||
# ================================================================
|
# ================================================================
|
||||||
# PAYMENT CONFIGURATION
|
# PAYMENT CONFIGURATION
|
||||||
# ================================================================
|
# ================================================================
|
||||||
STRIPE_PUBLISHABLE_KEY: "pk_test_your_stripe_publishable_key_here"
|
STRIPE_PUBLISHABLE_KEY: "pk_live_your_stripe_publishable_key_here"
|
||||||
SQUARE_APPLICATION_ID: "your-square-application-id"
|
SQUARE_APPLICATION_ID: "your-square-application-id"
|
||||||
SQUARE_ENVIRONMENT: "sandbox"
|
SQUARE_ENVIRONMENT: "production"
|
||||||
TOAST_ENVIRONMENT: "sandbox"
|
TOAST_ENVIRONMENT: "production"
|
||||||
LIGHTSPEED_ENVIRONMENT: "sandbox"
|
LIGHTSPEED_ENVIRONMENT: "production"
|
||||||
|
|
||||||
# ================================================================
|
# ================================================================
|
||||||
# EMAIL CONFIGURATION
|
# EMAIL CONFIGURATION
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
apiVersion: v1
|
|
||||||
kind: ConfigMap
|
|
||||||
metadata:
|
|
||||||
name: development-config
|
|
||||||
namespace: bakery-ia
|
|
||||||
labels:
|
|
||||||
app.kubernetes.io/component: config
|
|
||||||
app.kubernetes.io/part-of: bakery-ia
|
|
||||||
environment: development
|
|
||||||
data:
|
|
||||||
# Set to "true" to force recreate all tables from scratch (development mode)
|
|
||||||
# This will drop all existing tables and recreate them from SQLAlchemy models
|
|
||||||
DB_FORCE_RECREATE: "false"
|
|
||||||
|
|
||||||
# Development mode flag
|
|
||||||
DEVELOPMENT_MODE: "true"
|
|
||||||
|
|
||||||
# Enable debug logging in development
|
|
||||||
DEBUG_LOGGING: "true"
|
|
||||||
|
|
||||||
# Skip migration version checking in development
|
|
||||||
SKIP_MIGRATION_VERSION_CHECK: "false"
|
|
||||||
@@ -2,7 +2,6 @@ apiVersion: v1
|
|||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
metadata:
|
metadata:
|
||||||
name: postgres-init-config
|
name: postgres-init-config
|
||||||
namespace: bakery-ia
|
|
||||||
labels:
|
labels:
|
||||||
app.kubernetes.io/component: database
|
app.kubernetes.io/component: database
|
||||||
app.kubernetes.io/part-of: bakery-ia
|
app.kubernetes.io/part-of: bakery-ia
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ resources:
|
|||||||
|
|
||||||
# Additional configs
|
# Additional configs
|
||||||
- configs/postgres-init-config.yaml
|
- configs/postgres-init-config.yaml
|
||||||
- configs/development-config.yaml
|
|
||||||
|
|
||||||
# Migration jobs
|
# Migration jobs
|
||||||
- migrations/auth-migration-job.yaml
|
- migrations/auth-migration-job.yaml
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
apiVersion: v1
|
|
||||||
kind: ConfigMap
|
|
||||||
metadata:
|
|
||||||
name: bakery-config
|
|
||||||
namespace: bakery-ia
|
|
||||||
data:
|
|
||||||
# Development specific overrides
|
|
||||||
ENVIRONMENT: "development"
|
|
||||||
DEBUG: "true"
|
|
||||||
LOG_LEVEL: "DEBUG"
|
|
||||||
AUTO_RELOAD: "true"
|
|
||||||
PROFILING_ENABLED: "true"
|
|
||||||
MOCK_EXTERNAL_APIS: "true"
|
|
||||||
|
|
||||||
# CORS Configuration for Development
|
|
||||||
CORS_ORIGINS: "http://frontend-service:3000,http://localhost:3000,http://localhost:3001,http://localhost,http://127.0.0.1:3000,http://127.0.0.1:3001,http://bakery-ia.local,https://localhost,https://127.0.0.1"
|
|
||||||
|
|
||||||
# Frontend Development Configuration
|
|
||||||
VITE_ENVIRONMENT: "development"
|
|
||||||
VITE_API_URL: "/api"
|
|
||||||
@@ -11,7 +11,6 @@ resources:
|
|||||||
- dev-ingress.yaml
|
- dev-ingress.yaml
|
||||||
|
|
||||||
patches:
|
patches:
|
||||||
- path: dev-patches.yaml
|
|
||||||
- target:
|
- target:
|
||||||
group: apps
|
group: apps
|
||||||
version: v1
|
version: v1
|
||||||
@@ -487,13 +486,41 @@ patches:
|
|||||||
cpu: "500m"
|
cpu: "500m"
|
||||||
|
|
||||||
configMapGenerator:
|
configMapGenerator:
|
||||||
- name: bakery-dev-config
|
- name: bakery-config
|
||||||
|
behavior: merge
|
||||||
literals:
|
literals:
|
||||||
|
# Environment & Build Settings
|
||||||
- ENVIRONMENT=development
|
- ENVIRONMENT=development
|
||||||
- DEBUG=true
|
- DEBUG=true
|
||||||
- LOG_LEVEL=DEBUG
|
- LOG_LEVEL=DEBUG
|
||||||
- AUTO_RELOAD=true
|
- AUTO_RELOAD=true
|
||||||
- PROFILING_ENABLED=true
|
- PROFILING_ENABLED=true
|
||||||
|
- MOCK_EXTERNAL_APIS=true
|
||||||
|
- TESTING=false
|
||||||
|
- DOMAIN=localhost
|
||||||
|
- API_DOCS_ENABLED=true
|
||||||
|
|
||||||
|
# CORS Configuration for Development
|
||||||
|
- CORS_ORIGINS=http://frontend-service:3000,http://localhost:3000,http://localhost:3001,http://localhost,http://127.0.0.1:3000,http://127.0.0.1:3001,http://bakery-ia.local,https://localhost,https://127.0.0.1
|
||||||
|
|
||||||
|
# Frontend Development Configuration
|
||||||
|
- VITE_ENVIRONMENT=development
|
||||||
|
- VITE_API_URL=/api
|
||||||
|
|
||||||
|
# Payment Configuration (Sandbox for dev)
|
||||||
|
- STRIPE_PUBLISHABLE_KEY=pk_test_your_stripe_publishable_key_here
|
||||||
|
- SQUARE_ENVIRONMENT=sandbox
|
||||||
|
- TOAST_ENVIRONMENT=sandbox
|
||||||
|
- LIGHTSPEED_ENVIRONMENT=sandbox
|
||||||
|
|
||||||
|
# Rate Limiting (Disabled for dev)
|
||||||
|
- RATE_LIMIT_ENABLED=false
|
||||||
|
|
||||||
|
# Database (Development mode)
|
||||||
|
- DB_FORCE_RECREATE=false
|
||||||
|
- DEVELOPMENT_MODE=true
|
||||||
|
- DEBUG_LOGGING=true
|
||||||
|
- SKIP_MIGRATION_VERSION_CHECK=false
|
||||||
|
|
||||||
secretGenerator:
|
secretGenerator:
|
||||||
- name: dev-secrets
|
- name: dev-secrets
|
||||||
|
|||||||
85
infrastructure/kubernetes/overlays/prod/kustomization.yaml
Normal file
85
infrastructure/kubernetes/overlays/prod/kustomization.yaml
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
|
||||||
|
metadata:
|
||||||
|
name: bakery-ia-prod
|
||||||
|
|
||||||
|
namespace: bakery-ia
|
||||||
|
|
||||||
|
resources:
|
||||||
|
- ../../base
|
||||||
|
- prod-ingress.yaml
|
||||||
|
|
||||||
|
labels:
|
||||||
|
- includeSelectors: true
|
||||||
|
pairs:
|
||||||
|
environment: production
|
||||||
|
tier: production
|
||||||
|
|
||||||
|
images:
|
||||||
|
- name: bakery/auth-service
|
||||||
|
newTag: latest
|
||||||
|
- name: bakery/tenant-service
|
||||||
|
newTag: latest
|
||||||
|
- name: bakery/training-service
|
||||||
|
newTag: latest
|
||||||
|
- name: bakery/forecasting-service
|
||||||
|
newTag: latest
|
||||||
|
- name: bakery/sales-service
|
||||||
|
newTag: latest
|
||||||
|
- name: bakery/external-service
|
||||||
|
newTag: latest
|
||||||
|
- name: bakery/notification-service
|
||||||
|
newTag: latest
|
||||||
|
- name: bakery/inventory-service
|
||||||
|
newTag: latest
|
||||||
|
- name: bakery/recipes-service
|
||||||
|
newTag: latest
|
||||||
|
- name: bakery/suppliers-service
|
||||||
|
newTag: latest
|
||||||
|
- name: bakery/pos-service
|
||||||
|
newTag: latest
|
||||||
|
- name: bakery/orders-service
|
||||||
|
newTag: latest
|
||||||
|
- name: bakery/production-service
|
||||||
|
newTag: latest
|
||||||
|
- name: bakery/alert-processor
|
||||||
|
newTag: latest
|
||||||
|
- name: bakery/gateway
|
||||||
|
newTag: latest
|
||||||
|
- name: bakery/dashboard
|
||||||
|
newTag: latest
|
||||||
|
|
||||||
|
replicas:
|
||||||
|
- name: auth-service
|
||||||
|
count: 3
|
||||||
|
- name: tenant-service
|
||||||
|
count: 2
|
||||||
|
- name: training-service
|
||||||
|
count: 2
|
||||||
|
- name: forecasting-service
|
||||||
|
count: 3
|
||||||
|
- name: sales-service
|
||||||
|
count: 2
|
||||||
|
- name: external-service
|
||||||
|
count: 2
|
||||||
|
- name: notification-service
|
||||||
|
count: 3
|
||||||
|
- name: inventory-service
|
||||||
|
count: 2
|
||||||
|
- name: recipes-service
|
||||||
|
count: 2
|
||||||
|
- name: suppliers-service
|
||||||
|
count: 2
|
||||||
|
- name: pos-service
|
||||||
|
count: 2
|
||||||
|
- name: orders-service
|
||||||
|
count: 3
|
||||||
|
- name: production-service
|
||||||
|
count: 2
|
||||||
|
- name: alert-processor-service
|
||||||
|
count: 3
|
||||||
|
- name: gateway
|
||||||
|
count: 3
|
||||||
|
- name: frontend
|
||||||
|
count: 2
|
||||||
93
infrastructure/kubernetes/overlays/prod/prod-ingress.yaml
Normal file
93
infrastructure/kubernetes/overlays/prod/prod-ingress.yaml
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
apiVersion: networking.k8s.io/v1
|
||||||
|
kind: Ingress
|
||||||
|
metadata:
|
||||||
|
name: bakery-ingress-prod
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: bakery-ia
|
||||||
|
app.kubernetes.io/component: ingress
|
||||||
|
annotations:
|
||||||
|
# Nginx ingress controller annotations
|
||||||
|
nginx.ingress.kubernetes.io/ssl-redirect: "true"
|
||||||
|
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
|
||||||
|
nginx.ingress.kubernetes.io/proxy-body-size: "10m"
|
||||||
|
nginx.ingress.kubernetes.io/proxy-connect-timeout: "600"
|
||||||
|
nginx.ingress.kubernetes.io/proxy-send-timeout: "600"
|
||||||
|
nginx.ingress.kubernetes.io/proxy-read-timeout: "600"
|
||||||
|
|
||||||
|
# CORS configuration for production
|
||||||
|
nginx.ingress.kubernetes.io/enable-cors: "true"
|
||||||
|
nginx.ingress.kubernetes.io/cors-allow-origin: "https://bakery.yourdomain.com,https://api.yourdomain.com"
|
||||||
|
nginx.ingress.kubernetes.io/cors-allow-methods: "GET, POST, PUT, DELETE, OPTIONS, PATCH"
|
||||||
|
nginx.ingress.kubernetes.io/cors-allow-headers: "Content-Type, Authorization, X-Requested-With, Accept, Origin"
|
||||||
|
nginx.ingress.kubernetes.io/cors-allow-credentials: "true"
|
||||||
|
|
||||||
|
# Security headers
|
||||||
|
nginx.ingress.kubernetes.io/configuration-snippet: |
|
||||||
|
more_set_headers "X-Frame-Options: DENY";
|
||||||
|
more_set_headers "X-Content-Type-Options: nosniff";
|
||||||
|
more_set_headers "X-XSS-Protection: 1; mode=block";
|
||||||
|
more_set_headers "Referrer-Policy: strict-origin-when-cross-origin";
|
||||||
|
|
||||||
|
# Rate limiting
|
||||||
|
nginx.ingress.kubernetes.io/limit-rps: "100"
|
||||||
|
nginx.ingress.kubernetes.io/limit-connections: "50"
|
||||||
|
|
||||||
|
# Cert-manager annotations for automatic certificate issuance
|
||||||
|
cert-manager.io/cluster-issuer: "letsencrypt-production"
|
||||||
|
cert-manager.io/acme-challenge-type: http01
|
||||||
|
|
||||||
|
spec:
|
||||||
|
ingressClassName: nginx
|
||||||
|
tls:
|
||||||
|
- hosts:
|
||||||
|
- bakery.yourdomain.com
|
||||||
|
- api.yourdomain.com
|
||||||
|
- monitoring.yourdomain.com
|
||||||
|
secretName: bakery-ia-prod-tls-cert
|
||||||
|
rules:
|
||||||
|
- host: bakery.yourdomain.com
|
||||||
|
http:
|
||||||
|
paths:
|
||||||
|
- path: /
|
||||||
|
pathType: Prefix
|
||||||
|
backend:
|
||||||
|
service:
|
||||||
|
name: frontend-service
|
||||||
|
port:
|
||||||
|
number: 3000
|
||||||
|
- path: /api
|
||||||
|
pathType: Prefix
|
||||||
|
backend:
|
||||||
|
service:
|
||||||
|
name: gateway-service
|
||||||
|
port:
|
||||||
|
number: 8000
|
||||||
|
|
||||||
|
- host: api.yourdomain.com
|
||||||
|
http:
|
||||||
|
paths:
|
||||||
|
- path: /
|
||||||
|
pathType: Prefix
|
||||||
|
backend:
|
||||||
|
service:
|
||||||
|
name: gateway-service
|
||||||
|
port:
|
||||||
|
number: 8000
|
||||||
|
|
||||||
|
- host: monitoring.yourdomain.com
|
||||||
|
http:
|
||||||
|
paths:
|
||||||
|
- path: /grafana
|
||||||
|
pathType: Prefix
|
||||||
|
backend:
|
||||||
|
service:
|
||||||
|
name: grafana-service
|
||||||
|
port:
|
||||||
|
number: 3000
|
||||||
|
- path: /prometheus
|
||||||
|
pathType: Prefix
|
||||||
|
backend:
|
||||||
|
service:
|
||||||
|
name: prometheus-service
|
||||||
|
port:
|
||||||
|
number: 9090
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
"""Alembic environment configuration for forecasting service"""
|
|
||||||
|
|
||||||
import asyncio
|
|
||||||
import logging
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
from logging.config import fileConfig
|
|
||||||
from sqlalchemy import pool
|
|
||||||
from sqlalchemy.engine import Connection
|
|
||||||
from sqlalchemy.ext.asyncio import async_engine_from_config
|
|
||||||
from alembic import context
|
|
||||||
|
|
||||||
# Add the service directory to the Python path
|
|
||||||
service_path = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
|
||||||
if service_path not in sys.path:
|
|
||||||
sys.path.insert(0, service_path)
|
|
||||||
|
|
||||||
# Add shared modules to path
|
|
||||||
shared_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "shared"))
|
|
||||||
if shared_path not in sys.path:
|
|
||||||
sys.path.insert(0, shared_path)
|
|
||||||
|
|
||||||
try:
|
|
||||||
from app.core.config import settings
|
|
||||||
from shared.database.base import Base
|
|
||||||
|
|
||||||
# Import all models to ensure they are registered with Base.metadata
|
|
||||||
from app.models import * # Import all models
|
|
||||||
|
|
||||||
except ImportError as e:
|
|
||||||
print(f"Import error in migrations env.py: {e}")
|
|
||||||
print(f"Current Python path: {sys.path}")
|
|
||||||
raise
|
|
||||||
|
|
||||||
# this is the Alembic Config object
|
|
||||||
config = context.config
|
|
||||||
|
|
||||||
# Set database URL from environment variables or settings
|
|
||||||
database_url = os.getenv('FORECASTING_DATABASE_URL') or os.getenv('DATABASE_URL')
|
|
||||||
|
|
||||||
# If DATABASE_URL is not set, construct from individual components
|
|
||||||
if not database_url:
|
|
||||||
postgres_host = os.getenv('POSTGRES_HOST')
|
|
||||||
postgres_port = os.getenv('POSTGRES_PORT', '5432')
|
|
||||||
postgres_db = os.getenv('POSTGRES_DB')
|
|
||||||
postgres_user = os.getenv('POSTGRES_USER')
|
|
||||||
postgres_password = os.getenv('POSTGRES_PASSWORD')
|
|
||||||
|
|
||||||
if all([postgres_host, postgres_db, postgres_user, postgres_password]):
|
|
||||||
database_url = f"postgresql+asyncpg://{postgres_user}:{postgres_password}@{postgres_host}:{postgres_port}/{postgres_db}"
|
|
||||||
else:
|
|
||||||
# Fallback to settings
|
|
||||||
database_url = getattr(settings, 'DATABASE_URL', None)
|
|
||||||
|
|
||||||
if database_url:
|
|
||||||
config.set_main_option("sqlalchemy.url", database_url)
|
|
||||||
|
|
||||||
# Interpret the config file for Python logging
|
|
||||||
if config.config_file_name is not None:
|
|
||||||
fileConfig(config.config_file_name)
|
|
||||||
|
|
||||||
# Set target metadata
|
|
||||||
target_metadata = Base.metadata
|
|
||||||
|
|
||||||
def run_migrations_offline() -> None:
|
|
||||||
"""Run migrations in 'offline' mode."""
|
|
||||||
url = config.get_main_option("sqlalchemy.url")
|
|
||||||
context.configure(
|
|
||||||
url=url,
|
|
||||||
target_metadata=target_metadata,
|
|
||||||
literal_binds=True,
|
|
||||||
dialect_opts={"paramstyle": "named"},
|
|
||||||
compare_type=True,
|
|
||||||
compare_server_default=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
with context.begin_transaction():
|
|
||||||
context.run_migrations()
|
|
||||||
|
|
||||||
def do_run_migrations(connection: Connection) -> None:
|
|
||||||
context.configure(
|
|
||||||
connection=connection,
|
|
||||||
target_metadata=target_metadata,
|
|
||||||
compare_type=True,
|
|
||||||
compare_server_default=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
with context.begin_transaction():
|
|
||||||
context.run_migrations()
|
|
||||||
|
|
||||||
async def run_async_migrations() -> None:
|
|
||||||
"""Run migrations in 'online' mode."""
|
|
||||||
connectable = async_engine_from_config(
|
|
||||||
config.get_section(config.config_ini_section, {}),
|
|
||||||
prefix="sqlalchemy.",
|
|
||||||
poolclass=pool.NullPool,
|
|
||||||
)
|
|
||||||
|
|
||||||
async with connectable.connect() as connection:
|
|
||||||
await connection.run_sync(do_run_migrations)
|
|
||||||
|
|
||||||
await connectable.dispose()
|
|
||||||
|
|
||||||
def run_migrations_online() -> None:
|
|
||||||
"""Run migrations in 'online' mode."""
|
|
||||||
asyncio.run(run_async_migrations())
|
|
||||||
|
|
||||||
if context.is_offline_mode():
|
|
||||||
run_migrations_offline()
|
|
||||||
else:
|
|
||||||
run_migrations_online()
|
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
"""Alembic environment configuration for inventory service"""
|
|
||||||
|
|
||||||
import asyncio
|
|
||||||
import logging
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
from logging.config import fileConfig
|
|
||||||
from sqlalchemy import pool
|
|
||||||
from sqlalchemy.engine import Connection
|
|
||||||
from sqlalchemy.ext.asyncio import async_engine_from_config
|
|
||||||
from alembic import context
|
|
||||||
|
|
||||||
# Add the service directory to the Python path
|
|
||||||
service_path = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
|
||||||
if service_path not in sys.path:
|
|
||||||
sys.path.insert(0, service_path)
|
|
||||||
|
|
||||||
# Add shared modules to path
|
|
||||||
shared_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "shared"))
|
|
||||||
if shared_path not in sys.path:
|
|
||||||
sys.path.insert(0, shared_path)
|
|
||||||
|
|
||||||
try:
|
|
||||||
from app.core.config import settings
|
|
||||||
from shared.database.base import Base
|
|
||||||
|
|
||||||
# Import all models to ensure they are registered with Base.metadata
|
|
||||||
from app.models import * # Import all models
|
|
||||||
|
|
||||||
except ImportError as e:
|
|
||||||
print(f"Import error in migrations env.py: {e}")
|
|
||||||
print(f"Current Python path: {sys.path}")
|
|
||||||
raise
|
|
||||||
|
|
||||||
# this is the Alembic Config object
|
|
||||||
config = context.config
|
|
||||||
|
|
||||||
# Set database URL from environment variables or settings
|
|
||||||
database_url = os.getenv('INVENTORY_DATABASE_URL') or os.getenv('DATABASE_URL')
|
|
||||||
|
|
||||||
# If DATABASE_URL is not set, construct from individual components
|
|
||||||
if not database_url:
|
|
||||||
postgres_host = os.getenv('POSTGRES_HOST')
|
|
||||||
postgres_port = os.getenv('POSTGRES_PORT', '5432')
|
|
||||||
postgres_db = os.getenv('POSTGRES_DB')
|
|
||||||
postgres_user = os.getenv('POSTGRES_USER')
|
|
||||||
postgres_password = os.getenv('POSTGRES_PASSWORD')
|
|
||||||
|
|
||||||
if all([postgres_host, postgres_db, postgres_user, postgres_password]):
|
|
||||||
database_url = f"postgresql+asyncpg://{postgres_user}:{postgres_password}@{postgres_host}:{postgres_port}/{postgres_db}"
|
|
||||||
else:
|
|
||||||
# Fallback to settings
|
|
||||||
database_url = getattr(settings, 'DATABASE_URL', None)
|
|
||||||
|
|
||||||
if database_url:
|
|
||||||
config.set_main_option("sqlalchemy.url", database_url)
|
|
||||||
|
|
||||||
# Interpret the config file for Python logging
|
|
||||||
if config.config_file_name is not None:
|
|
||||||
fileConfig(config.config_file_name)
|
|
||||||
|
|
||||||
# Set target metadata
|
|
||||||
target_metadata = Base.metadata
|
|
||||||
|
|
||||||
def run_migrations_offline() -> None:
|
|
||||||
"""Run migrations in 'offline' mode."""
|
|
||||||
url = config.get_main_option("sqlalchemy.url")
|
|
||||||
context.configure(
|
|
||||||
url=url,
|
|
||||||
target_metadata=target_metadata,
|
|
||||||
literal_binds=True,
|
|
||||||
dialect_opts={"paramstyle": "named"},
|
|
||||||
compare_type=True,
|
|
||||||
compare_server_default=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
with context.begin_transaction():
|
|
||||||
context.run_migrations()
|
|
||||||
|
|
||||||
def do_run_migrations(connection: Connection) -> None:
|
|
||||||
context.configure(
|
|
||||||
connection=connection,
|
|
||||||
target_metadata=target_metadata,
|
|
||||||
compare_type=True,
|
|
||||||
compare_server_default=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
with context.begin_transaction():
|
|
||||||
context.run_migrations()
|
|
||||||
|
|
||||||
async def run_async_migrations() -> None:
|
|
||||||
"""Run migrations in 'online' mode."""
|
|
||||||
connectable = async_engine_from_config(
|
|
||||||
config.get_section(config.config_ini_section, {}),
|
|
||||||
prefix="sqlalchemy.",
|
|
||||||
poolclass=pool.NullPool,
|
|
||||||
)
|
|
||||||
|
|
||||||
async with connectable.connect() as connection:
|
|
||||||
await connection.run_sync(do_run_migrations)
|
|
||||||
|
|
||||||
await connectable.dispose()
|
|
||||||
|
|
||||||
def run_migrations_online() -> None:
|
|
||||||
"""Run migrations in 'online' mode."""
|
|
||||||
asyncio.run(run_async_migrations())
|
|
||||||
|
|
||||||
if context.is_offline_mode():
|
|
||||||
run_migrations_offline()
|
|
||||||
else:
|
|
||||||
run_migrations_online()
|
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
"""Alembic environment configuration for notification service"""
|
|
||||||
|
|
||||||
import asyncio
|
|
||||||
import logging
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
from logging.config import fileConfig
|
|
||||||
from sqlalchemy import pool
|
|
||||||
from sqlalchemy.engine import Connection
|
|
||||||
from sqlalchemy.ext.asyncio import async_engine_from_config
|
|
||||||
from alembic import context
|
|
||||||
|
|
||||||
# Add the service directory to the Python path
|
|
||||||
service_path = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
|
||||||
if service_path not in sys.path:
|
|
||||||
sys.path.insert(0, service_path)
|
|
||||||
|
|
||||||
# Add shared modules to path
|
|
||||||
shared_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "shared"))
|
|
||||||
if shared_path not in sys.path:
|
|
||||||
sys.path.insert(0, shared_path)
|
|
||||||
|
|
||||||
try:
|
|
||||||
from app.core.config import settings
|
|
||||||
from shared.database.base import Base
|
|
||||||
|
|
||||||
# Import all models to ensure they are registered with Base.metadata
|
|
||||||
from app.models import * # Import all models
|
|
||||||
|
|
||||||
except ImportError as e:
|
|
||||||
print(f"Import error in migrations env.py: {e}")
|
|
||||||
print(f"Current Python path: {sys.path}")
|
|
||||||
raise
|
|
||||||
|
|
||||||
# this is the Alembic Config object
|
|
||||||
config = context.config
|
|
||||||
|
|
||||||
# Set database URL from environment variables or settings
|
|
||||||
database_url = os.getenv('NOTIFICATION_DATABASE_URL') or os.getenv('DATABASE_URL')
|
|
||||||
|
|
||||||
# If DATABASE_URL is not set, construct from individual components
|
|
||||||
if not database_url:
|
|
||||||
postgres_host = os.getenv('POSTGRES_HOST')
|
|
||||||
postgres_port = os.getenv('POSTGRES_PORT', '5432')
|
|
||||||
postgres_db = os.getenv('POSTGRES_DB')
|
|
||||||
postgres_user = os.getenv('POSTGRES_USER')
|
|
||||||
postgres_password = os.getenv('POSTGRES_PASSWORD')
|
|
||||||
|
|
||||||
if all([postgres_host, postgres_db, postgres_user, postgres_password]):
|
|
||||||
database_url = f"postgresql+asyncpg://{postgres_user}:{postgres_password}@{postgres_host}:{postgres_port}/{postgres_db}"
|
|
||||||
else:
|
|
||||||
# Fallback to settings
|
|
||||||
database_url = getattr(settings, 'DATABASE_URL', None)
|
|
||||||
|
|
||||||
if database_url:
|
|
||||||
config.set_main_option("sqlalchemy.url", database_url)
|
|
||||||
|
|
||||||
# Interpret the config file for Python logging
|
|
||||||
if config.config_file_name is not None:
|
|
||||||
fileConfig(config.config_file_name)
|
|
||||||
|
|
||||||
# Set target metadata
|
|
||||||
target_metadata = Base.metadata
|
|
||||||
|
|
||||||
def run_migrations_offline() -> None:
|
|
||||||
"""Run migrations in 'offline' mode."""
|
|
||||||
url = config.get_main_option("sqlalchemy.url")
|
|
||||||
context.configure(
|
|
||||||
url=url,
|
|
||||||
target_metadata=target_metadata,
|
|
||||||
literal_binds=True,
|
|
||||||
dialect_opts={"paramstyle": "named"},
|
|
||||||
compare_type=True,
|
|
||||||
compare_server_default=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
with context.begin_transaction():
|
|
||||||
context.run_migrations()
|
|
||||||
|
|
||||||
def do_run_migrations(connection: Connection) -> None:
|
|
||||||
context.configure(
|
|
||||||
connection=connection,
|
|
||||||
target_metadata=target_metadata,
|
|
||||||
compare_type=True,
|
|
||||||
compare_server_default=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
with context.begin_transaction():
|
|
||||||
context.run_migrations()
|
|
||||||
|
|
||||||
async def run_async_migrations() -> None:
|
|
||||||
"""Run migrations in 'online' mode."""
|
|
||||||
connectable = async_engine_from_config(
|
|
||||||
config.get_section(config.config_ini_section, {}),
|
|
||||||
prefix="sqlalchemy.",
|
|
||||||
poolclass=pool.NullPool,
|
|
||||||
)
|
|
||||||
|
|
||||||
async with connectable.connect() as connection:
|
|
||||||
await connection.run_sync(do_run_migrations)
|
|
||||||
|
|
||||||
await connectable.dispose()
|
|
||||||
|
|
||||||
def run_migrations_online() -> None:
|
|
||||||
"""Run migrations in 'online' mode."""
|
|
||||||
asyncio.run(run_async_migrations())
|
|
||||||
|
|
||||||
if context.is_offline_mode():
|
|
||||||
run_migrations_offline()
|
|
||||||
else:
|
|
||||||
run_migrations_online()
|
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
"""Alembic environment configuration for orders service"""
|
|
||||||
|
|
||||||
import asyncio
|
|
||||||
import logging
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
from logging.config import fileConfig
|
|
||||||
from sqlalchemy import pool
|
|
||||||
from sqlalchemy.engine import Connection
|
|
||||||
from sqlalchemy.ext.asyncio import async_engine_from_config
|
|
||||||
from alembic import context
|
|
||||||
|
|
||||||
# Add the service directory to the Python path
|
|
||||||
service_path = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
|
||||||
if service_path not in sys.path:
|
|
||||||
sys.path.insert(0, service_path)
|
|
||||||
|
|
||||||
# Add shared modules to path
|
|
||||||
shared_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "shared"))
|
|
||||||
if shared_path not in sys.path:
|
|
||||||
sys.path.insert(0, shared_path)
|
|
||||||
|
|
||||||
try:
|
|
||||||
from app.core.config import settings
|
|
||||||
from shared.database.base import Base
|
|
||||||
|
|
||||||
# Import all models to ensure they are registered with Base.metadata
|
|
||||||
from app.models import * # Import all models
|
|
||||||
|
|
||||||
except ImportError as e:
|
|
||||||
print(f"Import error in migrations env.py: {e}")
|
|
||||||
print(f"Current Python path: {sys.path}")
|
|
||||||
raise
|
|
||||||
|
|
||||||
# this is the Alembic Config object
|
|
||||||
config = context.config
|
|
||||||
|
|
||||||
# Set database URL from environment variables or settings
|
|
||||||
database_url = os.getenv('ORDERS_DATABASE_URL') or os.getenv('DATABASE_URL')
|
|
||||||
|
|
||||||
# If DATABASE_URL is not set, construct from individual components
|
|
||||||
if not database_url:
|
|
||||||
postgres_host = os.getenv('POSTGRES_HOST')
|
|
||||||
postgres_port = os.getenv('POSTGRES_PORT', '5432')
|
|
||||||
postgres_db = os.getenv('POSTGRES_DB')
|
|
||||||
postgres_user = os.getenv('POSTGRES_USER')
|
|
||||||
postgres_password = os.getenv('POSTGRES_PASSWORD')
|
|
||||||
|
|
||||||
if all([postgres_host, postgres_db, postgres_user, postgres_password]):
|
|
||||||
database_url = f"postgresql+asyncpg://{postgres_user}:{postgres_password}@{postgres_host}:{postgres_port}/{postgres_db}"
|
|
||||||
else:
|
|
||||||
# Fallback to settings
|
|
||||||
database_url = getattr(settings, 'DATABASE_URL', None)
|
|
||||||
|
|
||||||
if database_url:
|
|
||||||
config.set_main_option("sqlalchemy.url", database_url)
|
|
||||||
|
|
||||||
# Interpret the config file for Python logging
|
|
||||||
if config.config_file_name is not None:
|
|
||||||
fileConfig(config.config_file_name)
|
|
||||||
|
|
||||||
# Set target metadata
|
|
||||||
target_metadata = Base.metadata
|
|
||||||
|
|
||||||
def run_migrations_offline() -> None:
|
|
||||||
"""Run migrations in 'offline' mode."""
|
|
||||||
url = config.get_main_option("sqlalchemy.url")
|
|
||||||
context.configure(
|
|
||||||
url=url,
|
|
||||||
target_metadata=target_metadata,
|
|
||||||
literal_binds=True,
|
|
||||||
dialect_opts={"paramstyle": "named"},
|
|
||||||
compare_type=True,
|
|
||||||
compare_server_default=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
with context.begin_transaction():
|
|
||||||
context.run_migrations()
|
|
||||||
|
|
||||||
def do_run_migrations(connection: Connection) -> None:
|
|
||||||
context.configure(
|
|
||||||
connection=connection,
|
|
||||||
target_metadata=target_metadata,
|
|
||||||
compare_type=True,
|
|
||||||
compare_server_default=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
with context.begin_transaction():
|
|
||||||
context.run_migrations()
|
|
||||||
|
|
||||||
async def run_async_migrations() -> None:
|
|
||||||
"""Run migrations in 'online' mode."""
|
|
||||||
connectable = async_engine_from_config(
|
|
||||||
config.get_section(config.config_ini_section, {}),
|
|
||||||
prefix="sqlalchemy.",
|
|
||||||
poolclass=pool.NullPool,
|
|
||||||
)
|
|
||||||
|
|
||||||
async with connectable.connect() as connection:
|
|
||||||
await connection.run_sync(do_run_migrations)
|
|
||||||
|
|
||||||
await connectable.dispose()
|
|
||||||
|
|
||||||
def run_migrations_online() -> None:
|
|
||||||
"""Run migrations in 'online' mode."""
|
|
||||||
asyncio.run(run_async_migrations())
|
|
||||||
|
|
||||||
if context.is_offline_mode():
|
|
||||||
run_migrations_offline()
|
|
||||||
else:
|
|
||||||
run_migrations_online()
|
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
"""Alembic environment configuration for pos service"""
|
|
||||||
|
|
||||||
import asyncio
|
|
||||||
import logging
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
from logging.config import fileConfig
|
|
||||||
from sqlalchemy import pool
|
|
||||||
from sqlalchemy.engine import Connection
|
|
||||||
from sqlalchemy.ext.asyncio import async_engine_from_config
|
|
||||||
from alembic import context
|
|
||||||
|
|
||||||
# Add the service directory to the Python path
|
|
||||||
service_path = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
|
||||||
if service_path not in sys.path:
|
|
||||||
sys.path.insert(0, service_path)
|
|
||||||
|
|
||||||
# Add shared modules to path
|
|
||||||
shared_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "shared"))
|
|
||||||
if shared_path not in sys.path:
|
|
||||||
sys.path.insert(0, shared_path)
|
|
||||||
|
|
||||||
try:
|
|
||||||
from app.core.config import settings
|
|
||||||
from shared.database.base import Base
|
|
||||||
|
|
||||||
# Import all models to ensure they are registered with Base.metadata
|
|
||||||
from app.models import * # Import all models
|
|
||||||
|
|
||||||
except ImportError as e:
|
|
||||||
print(f"Import error in migrations env.py: {e}")
|
|
||||||
print(f"Current Python path: {sys.path}")
|
|
||||||
raise
|
|
||||||
|
|
||||||
# this is the Alembic Config object
|
|
||||||
config = context.config
|
|
||||||
|
|
||||||
# Set database URL from environment variables or settings
|
|
||||||
database_url = os.getenv('POS_DATABASE_URL') or os.getenv('DATABASE_URL')
|
|
||||||
|
|
||||||
# If DATABASE_URL is not set, construct from individual components
|
|
||||||
if not database_url:
|
|
||||||
postgres_host = os.getenv('POSTGRES_HOST')
|
|
||||||
postgres_port = os.getenv('POSTGRES_PORT', '5432')
|
|
||||||
postgres_db = os.getenv('POSTGRES_DB')
|
|
||||||
postgres_user = os.getenv('POSTGRES_USER')
|
|
||||||
postgres_password = os.getenv('POSTGRES_PASSWORD')
|
|
||||||
|
|
||||||
if all([postgres_host, postgres_db, postgres_user, postgres_password]):
|
|
||||||
database_url = f"postgresql+asyncpg://{postgres_user}:{postgres_password}@{postgres_host}:{postgres_port}/{postgres_db}"
|
|
||||||
else:
|
|
||||||
# Fallback to settings
|
|
||||||
database_url = getattr(settings, 'DATABASE_URL', None)
|
|
||||||
|
|
||||||
if database_url:
|
|
||||||
config.set_main_option("sqlalchemy.url", database_url)
|
|
||||||
|
|
||||||
# Interpret the config file for Python logging
|
|
||||||
if config.config_file_name is not None:
|
|
||||||
fileConfig(config.config_file_name)
|
|
||||||
|
|
||||||
# Set target metadata
|
|
||||||
target_metadata = Base.metadata
|
|
||||||
|
|
||||||
def run_migrations_offline() -> None:
|
|
||||||
"""Run migrations in 'offline' mode."""
|
|
||||||
url = config.get_main_option("sqlalchemy.url")
|
|
||||||
context.configure(
|
|
||||||
url=url,
|
|
||||||
target_metadata=target_metadata,
|
|
||||||
literal_binds=True,
|
|
||||||
dialect_opts={"paramstyle": "named"},
|
|
||||||
compare_type=True,
|
|
||||||
compare_server_default=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
with context.begin_transaction():
|
|
||||||
context.run_migrations()
|
|
||||||
|
|
||||||
def do_run_migrations(connection: Connection) -> None:
|
|
||||||
context.configure(
|
|
||||||
connection=connection,
|
|
||||||
target_metadata=target_metadata,
|
|
||||||
compare_type=True,
|
|
||||||
compare_server_default=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
with context.begin_transaction():
|
|
||||||
context.run_migrations()
|
|
||||||
|
|
||||||
async def run_async_migrations() -> None:
|
|
||||||
"""Run migrations in 'online' mode."""
|
|
||||||
connectable = async_engine_from_config(
|
|
||||||
config.get_section(config.config_ini_section, {}),
|
|
||||||
prefix="sqlalchemy.",
|
|
||||||
poolclass=pool.NullPool,
|
|
||||||
)
|
|
||||||
|
|
||||||
async with connectable.connect() as connection:
|
|
||||||
await connection.run_sync(do_run_migrations)
|
|
||||||
|
|
||||||
await connectable.dispose()
|
|
||||||
|
|
||||||
def run_migrations_online() -> None:
|
|
||||||
"""Run migrations in 'online' mode."""
|
|
||||||
asyncio.run(run_async_migrations())
|
|
||||||
|
|
||||||
if context.is_offline_mode():
|
|
||||||
run_migrations_offline()
|
|
||||||
else:
|
|
||||||
run_migrations_online()
|
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
"""Alembic environment configuration for production service"""
|
|
||||||
|
|
||||||
import asyncio
|
|
||||||
import logging
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
from logging.config import fileConfig
|
|
||||||
from sqlalchemy import pool
|
|
||||||
from sqlalchemy.engine import Connection
|
|
||||||
from sqlalchemy.ext.asyncio import async_engine_from_config
|
|
||||||
from alembic import context
|
|
||||||
|
|
||||||
# Add the service directory to the Python path
|
|
||||||
service_path = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
|
||||||
if service_path not in sys.path:
|
|
||||||
sys.path.insert(0, service_path)
|
|
||||||
|
|
||||||
# Add shared modules to path
|
|
||||||
shared_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "shared"))
|
|
||||||
if shared_path not in sys.path:
|
|
||||||
sys.path.insert(0, shared_path)
|
|
||||||
|
|
||||||
try:
|
|
||||||
from app.core.config import settings
|
|
||||||
from shared.database.base import Base
|
|
||||||
|
|
||||||
# Import all models to ensure they are registered with Base.metadata
|
|
||||||
from app.models import * # Import all models
|
|
||||||
|
|
||||||
except ImportError as e:
|
|
||||||
print(f"Import error in migrations env.py: {e}")
|
|
||||||
print(f"Current Python path: {sys.path}")
|
|
||||||
raise
|
|
||||||
|
|
||||||
# this is the Alembic Config object
|
|
||||||
config = context.config
|
|
||||||
|
|
||||||
# Set database URL from environment variables or settings
|
|
||||||
database_url = os.getenv('PRODUCTION_DATABASE_URL') or os.getenv('DATABASE_URL')
|
|
||||||
|
|
||||||
# If DATABASE_URL is not set, construct from individual components
|
|
||||||
if not database_url:
|
|
||||||
postgres_host = os.getenv('POSTGRES_HOST')
|
|
||||||
postgres_port = os.getenv('POSTGRES_PORT', '5432')
|
|
||||||
postgres_db = os.getenv('POSTGRES_DB')
|
|
||||||
postgres_user = os.getenv('POSTGRES_USER')
|
|
||||||
postgres_password = os.getenv('POSTGRES_PASSWORD')
|
|
||||||
|
|
||||||
if all([postgres_host, postgres_db, postgres_user, postgres_password]):
|
|
||||||
database_url = f"postgresql+asyncpg://{postgres_user}:{postgres_password}@{postgres_host}:{postgres_port}/{postgres_db}"
|
|
||||||
else:
|
|
||||||
# Fallback to settings
|
|
||||||
database_url = getattr(settings, 'DATABASE_URL', None)
|
|
||||||
|
|
||||||
if database_url:
|
|
||||||
config.set_main_option("sqlalchemy.url", database_url)
|
|
||||||
|
|
||||||
# Interpret the config file for Python logging
|
|
||||||
if config.config_file_name is not None:
|
|
||||||
fileConfig(config.config_file_name)
|
|
||||||
|
|
||||||
# Set target metadata
|
|
||||||
target_metadata = Base.metadata
|
|
||||||
|
|
||||||
def run_migrations_offline() -> None:
|
|
||||||
"""Run migrations in 'offline' mode."""
|
|
||||||
url = config.get_main_option("sqlalchemy.url")
|
|
||||||
context.configure(
|
|
||||||
url=url,
|
|
||||||
target_metadata=target_metadata,
|
|
||||||
literal_binds=True,
|
|
||||||
dialect_opts={"paramstyle": "named"},
|
|
||||||
compare_type=True,
|
|
||||||
compare_server_default=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
with context.begin_transaction():
|
|
||||||
context.run_migrations()
|
|
||||||
|
|
||||||
def do_run_migrations(connection: Connection) -> None:
|
|
||||||
context.configure(
|
|
||||||
connection=connection,
|
|
||||||
target_metadata=target_metadata,
|
|
||||||
compare_type=True,
|
|
||||||
compare_server_default=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
with context.begin_transaction():
|
|
||||||
context.run_migrations()
|
|
||||||
|
|
||||||
async def run_async_migrations() -> None:
|
|
||||||
"""Run migrations in 'online' mode."""
|
|
||||||
connectable = async_engine_from_config(
|
|
||||||
config.get_section(config.config_ini_section, {}),
|
|
||||||
prefix="sqlalchemy.",
|
|
||||||
poolclass=pool.NullPool,
|
|
||||||
)
|
|
||||||
|
|
||||||
async with connectable.connect() as connection:
|
|
||||||
await connection.run_sync(do_run_migrations)
|
|
||||||
|
|
||||||
await connectable.dispose()
|
|
||||||
|
|
||||||
def run_migrations_online() -> None:
|
|
||||||
"""Run migrations in 'online' mode."""
|
|
||||||
asyncio.run(run_async_migrations())
|
|
||||||
|
|
||||||
if context.is_offline_mode():
|
|
||||||
run_migrations_offline()
|
|
||||||
else:
|
|
||||||
run_migrations_online()
|
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
"""Alembic environment configuration for recipes service"""
|
|
||||||
|
|
||||||
import asyncio
|
|
||||||
import logging
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
from logging.config import fileConfig
|
|
||||||
from sqlalchemy import pool
|
|
||||||
from sqlalchemy.engine import Connection
|
|
||||||
from sqlalchemy.ext.asyncio import async_engine_from_config
|
|
||||||
from alembic import context
|
|
||||||
|
|
||||||
# Add the service directory to the Python path
|
|
||||||
service_path = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
|
||||||
if service_path not in sys.path:
|
|
||||||
sys.path.insert(0, service_path)
|
|
||||||
|
|
||||||
# Add shared modules to path
|
|
||||||
shared_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "shared"))
|
|
||||||
if shared_path not in sys.path:
|
|
||||||
sys.path.insert(0, shared_path)
|
|
||||||
|
|
||||||
try:
|
|
||||||
from app.core.config import settings
|
|
||||||
from shared.database.base import Base
|
|
||||||
|
|
||||||
# Import all models to ensure they are registered with Base.metadata
|
|
||||||
from app.models import * # Import all models
|
|
||||||
|
|
||||||
except ImportError as e:
|
|
||||||
print(f"Import error in migrations env.py: {e}")
|
|
||||||
print(f"Current Python path: {sys.path}")
|
|
||||||
raise
|
|
||||||
|
|
||||||
# this is the Alembic Config object
|
|
||||||
config = context.config
|
|
||||||
|
|
||||||
# Set database URL from environment variables or settings
|
|
||||||
database_url = os.getenv('RECIPES_DATABASE_URL') or os.getenv('DATABASE_URL')
|
|
||||||
|
|
||||||
# If DATABASE_URL is not set, construct from individual components
|
|
||||||
if not database_url:
|
|
||||||
postgres_host = os.getenv('POSTGRES_HOST')
|
|
||||||
postgres_port = os.getenv('POSTGRES_PORT', '5432')
|
|
||||||
postgres_db = os.getenv('POSTGRES_DB')
|
|
||||||
postgres_user = os.getenv('POSTGRES_USER')
|
|
||||||
postgres_password = os.getenv('POSTGRES_PASSWORD')
|
|
||||||
|
|
||||||
if all([postgres_host, postgres_db, postgres_user, postgres_password]):
|
|
||||||
database_url = f"postgresql+asyncpg://{postgres_user}:{postgres_password}@{postgres_host}:{postgres_port}/{postgres_db}"
|
|
||||||
else:
|
|
||||||
# Fallback to settings
|
|
||||||
database_url = getattr(settings, 'DATABASE_URL', None)
|
|
||||||
|
|
||||||
if database_url:
|
|
||||||
config.set_main_option("sqlalchemy.url", database_url)
|
|
||||||
|
|
||||||
# Interpret the config file for Python logging
|
|
||||||
if config.config_file_name is not None:
|
|
||||||
fileConfig(config.config_file_name)
|
|
||||||
|
|
||||||
# Set target metadata
|
|
||||||
target_metadata = Base.metadata
|
|
||||||
|
|
||||||
def run_migrations_offline() -> None:
|
|
||||||
"""Run migrations in 'offline' mode."""
|
|
||||||
url = config.get_main_option("sqlalchemy.url")
|
|
||||||
context.configure(
|
|
||||||
url=url,
|
|
||||||
target_metadata=target_metadata,
|
|
||||||
literal_binds=True,
|
|
||||||
dialect_opts={"paramstyle": "named"},
|
|
||||||
compare_type=True,
|
|
||||||
compare_server_default=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
with context.begin_transaction():
|
|
||||||
context.run_migrations()
|
|
||||||
|
|
||||||
def do_run_migrations(connection: Connection) -> None:
|
|
||||||
context.configure(
|
|
||||||
connection=connection,
|
|
||||||
target_metadata=target_metadata,
|
|
||||||
compare_type=True,
|
|
||||||
compare_server_default=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
with context.begin_transaction():
|
|
||||||
context.run_migrations()
|
|
||||||
|
|
||||||
async def run_async_migrations() -> None:
|
|
||||||
"""Run migrations in 'online' mode."""
|
|
||||||
connectable = async_engine_from_config(
|
|
||||||
config.get_section(config.config_ini_section, {}),
|
|
||||||
prefix="sqlalchemy.",
|
|
||||||
poolclass=pool.NullPool,
|
|
||||||
)
|
|
||||||
|
|
||||||
async with connectable.connect() as connection:
|
|
||||||
await connection.run_sync(do_run_migrations)
|
|
||||||
|
|
||||||
await connectable.dispose()
|
|
||||||
|
|
||||||
def run_migrations_online() -> None:
|
|
||||||
"""Run migrations in 'online' mode."""
|
|
||||||
asyncio.run(run_async_migrations())
|
|
||||||
|
|
||||||
if context.is_offline_mode():
|
|
||||||
run_migrations_offline()
|
|
||||||
else:
|
|
||||||
run_migrations_online()
|
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
"""Alembic environment configuration for sales service"""
|
|
||||||
|
|
||||||
import asyncio
|
|
||||||
import logging
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
from logging.config import fileConfig
|
|
||||||
from sqlalchemy import pool
|
|
||||||
from sqlalchemy.engine import Connection
|
|
||||||
from sqlalchemy.ext.asyncio import async_engine_from_config
|
|
||||||
from alembic import context
|
|
||||||
|
|
||||||
# Add the service directory to the Python path
|
|
||||||
service_path = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
|
||||||
if service_path not in sys.path:
|
|
||||||
sys.path.insert(0, service_path)
|
|
||||||
|
|
||||||
# Add shared modules to path
|
|
||||||
shared_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "shared"))
|
|
||||||
if shared_path not in sys.path:
|
|
||||||
sys.path.insert(0, shared_path)
|
|
||||||
|
|
||||||
try:
|
|
||||||
from app.core.config import settings
|
|
||||||
from shared.database.base import Base
|
|
||||||
|
|
||||||
# Import all models to ensure they are registered with Base.metadata
|
|
||||||
from app.models import * # Import all models
|
|
||||||
|
|
||||||
except ImportError as e:
|
|
||||||
print(f"Import error in migrations env.py: {e}")
|
|
||||||
print(f"Current Python path: {sys.path}")
|
|
||||||
raise
|
|
||||||
|
|
||||||
# this is the Alembic Config object
|
|
||||||
config = context.config
|
|
||||||
|
|
||||||
# Set database URL from environment variables or settings
|
|
||||||
database_url = os.getenv('SALES_DATABASE_URL') or os.getenv('DATABASE_URL')
|
|
||||||
|
|
||||||
# If DATABASE_URL is not set, construct from individual components
|
|
||||||
if not database_url:
|
|
||||||
postgres_host = os.getenv('POSTGRES_HOST')
|
|
||||||
postgres_port = os.getenv('POSTGRES_PORT', '5432')
|
|
||||||
postgres_db = os.getenv('POSTGRES_DB')
|
|
||||||
postgres_user = os.getenv('POSTGRES_USER')
|
|
||||||
postgres_password = os.getenv('POSTGRES_PASSWORD')
|
|
||||||
|
|
||||||
if all([postgres_host, postgres_db, postgres_user, postgres_password]):
|
|
||||||
database_url = f"postgresql+asyncpg://{postgres_user}:{postgres_password}@{postgres_host}:{postgres_port}/{postgres_db}"
|
|
||||||
else:
|
|
||||||
# Fallback to settings
|
|
||||||
database_url = getattr(settings, 'DATABASE_URL', None)
|
|
||||||
|
|
||||||
if database_url:
|
|
||||||
config.set_main_option("sqlalchemy.url", database_url)
|
|
||||||
|
|
||||||
# Interpret the config file for Python logging
|
|
||||||
if config.config_file_name is not None:
|
|
||||||
fileConfig(config.config_file_name)
|
|
||||||
|
|
||||||
# Set target metadata
|
|
||||||
target_metadata = Base.metadata
|
|
||||||
|
|
||||||
def run_migrations_offline() -> None:
|
|
||||||
"""Run migrations in 'offline' mode."""
|
|
||||||
url = config.get_main_option("sqlalchemy.url")
|
|
||||||
context.configure(
|
|
||||||
url=url,
|
|
||||||
target_metadata=target_metadata,
|
|
||||||
literal_binds=True,
|
|
||||||
dialect_opts={"paramstyle": "named"},
|
|
||||||
compare_type=True,
|
|
||||||
compare_server_default=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
with context.begin_transaction():
|
|
||||||
context.run_migrations()
|
|
||||||
|
|
||||||
def do_run_migrations(connection: Connection) -> None:
|
|
||||||
context.configure(
|
|
||||||
connection=connection,
|
|
||||||
target_metadata=target_metadata,
|
|
||||||
compare_type=True,
|
|
||||||
compare_server_default=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
with context.begin_transaction():
|
|
||||||
context.run_migrations()
|
|
||||||
|
|
||||||
async def run_async_migrations() -> None:
|
|
||||||
"""Run migrations in 'online' mode."""
|
|
||||||
connectable = async_engine_from_config(
|
|
||||||
config.get_section(config.config_ini_section, {}),
|
|
||||||
prefix="sqlalchemy.",
|
|
||||||
poolclass=pool.NullPool,
|
|
||||||
)
|
|
||||||
|
|
||||||
async with connectable.connect() as connection:
|
|
||||||
await connection.run_sync(do_run_migrations)
|
|
||||||
|
|
||||||
await connectable.dispose()
|
|
||||||
|
|
||||||
def run_migrations_online() -> None:
|
|
||||||
"""Run migrations in 'online' mode."""
|
|
||||||
asyncio.run(run_async_migrations())
|
|
||||||
|
|
||||||
if context.is_offline_mode():
|
|
||||||
run_migrations_offline()
|
|
||||||
else:
|
|
||||||
run_migrations_online()
|
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
"""Alembic environment configuration for suppliers service"""
|
|
||||||
|
|
||||||
import asyncio
|
|
||||||
import logging
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
from logging.config import fileConfig
|
|
||||||
from sqlalchemy import pool
|
|
||||||
from sqlalchemy.engine import Connection
|
|
||||||
from sqlalchemy.ext.asyncio import async_engine_from_config
|
|
||||||
from alembic import context
|
|
||||||
|
|
||||||
# Add the service directory to the Python path
|
|
||||||
service_path = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
|
||||||
if service_path not in sys.path:
|
|
||||||
sys.path.insert(0, service_path)
|
|
||||||
|
|
||||||
# Add shared modules to path
|
|
||||||
shared_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "shared"))
|
|
||||||
if shared_path not in sys.path:
|
|
||||||
sys.path.insert(0, shared_path)
|
|
||||||
|
|
||||||
try:
|
|
||||||
from app.core.config import settings
|
|
||||||
from shared.database.base import Base
|
|
||||||
|
|
||||||
# Import all models to ensure they are registered with Base.metadata
|
|
||||||
from app.models import * # Import all models
|
|
||||||
|
|
||||||
except ImportError as e:
|
|
||||||
print(f"Import error in migrations env.py: {e}")
|
|
||||||
print(f"Current Python path: {sys.path}")
|
|
||||||
raise
|
|
||||||
|
|
||||||
# this is the Alembic Config object
|
|
||||||
config = context.config
|
|
||||||
|
|
||||||
# Set database URL from environment variables or settings
|
|
||||||
database_url = os.getenv('SUPPLIERS_DATABASE_URL') or os.getenv('DATABASE_URL')
|
|
||||||
|
|
||||||
# If DATABASE_URL is not set, construct from individual components
|
|
||||||
if not database_url:
|
|
||||||
postgres_host = os.getenv('POSTGRES_HOST')
|
|
||||||
postgres_port = os.getenv('POSTGRES_PORT', '5432')
|
|
||||||
postgres_db = os.getenv('POSTGRES_DB')
|
|
||||||
postgres_user = os.getenv('POSTGRES_USER')
|
|
||||||
postgres_password = os.getenv('POSTGRES_PASSWORD')
|
|
||||||
|
|
||||||
if all([postgres_host, postgres_db, postgres_user, postgres_password]):
|
|
||||||
database_url = f"postgresql+asyncpg://{postgres_user}:{postgres_password}@{postgres_host}:{postgres_port}/{postgres_db}"
|
|
||||||
else:
|
|
||||||
# Fallback to settings
|
|
||||||
database_url = getattr(settings, 'DATABASE_URL', None)
|
|
||||||
|
|
||||||
if database_url:
|
|
||||||
config.set_main_option("sqlalchemy.url", database_url)
|
|
||||||
|
|
||||||
# Interpret the config file for Python logging
|
|
||||||
if config.config_file_name is not None:
|
|
||||||
fileConfig(config.config_file_name)
|
|
||||||
|
|
||||||
# Set target metadata
|
|
||||||
target_metadata = Base.metadata
|
|
||||||
|
|
||||||
def run_migrations_offline() -> None:
|
|
||||||
"""Run migrations in 'offline' mode."""
|
|
||||||
url = config.get_main_option("sqlalchemy.url")
|
|
||||||
context.configure(
|
|
||||||
url=url,
|
|
||||||
target_metadata=target_metadata,
|
|
||||||
literal_binds=True,
|
|
||||||
dialect_opts={"paramstyle": "named"},
|
|
||||||
compare_type=True,
|
|
||||||
compare_server_default=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
with context.begin_transaction():
|
|
||||||
context.run_migrations()
|
|
||||||
|
|
||||||
def do_run_migrations(connection: Connection) -> None:
|
|
||||||
context.configure(
|
|
||||||
connection=connection,
|
|
||||||
target_metadata=target_metadata,
|
|
||||||
compare_type=True,
|
|
||||||
compare_server_default=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
with context.begin_transaction():
|
|
||||||
context.run_migrations()
|
|
||||||
|
|
||||||
async def run_async_migrations() -> None:
|
|
||||||
"""Run migrations in 'online' mode."""
|
|
||||||
connectable = async_engine_from_config(
|
|
||||||
config.get_section(config.config_ini_section, {}),
|
|
||||||
prefix="sqlalchemy.",
|
|
||||||
poolclass=pool.NullPool,
|
|
||||||
)
|
|
||||||
|
|
||||||
async with connectable.connect() as connection:
|
|
||||||
await connection.run_sync(do_run_migrations)
|
|
||||||
|
|
||||||
await connectable.dispose()
|
|
||||||
|
|
||||||
def run_migrations_online() -> None:
|
|
||||||
"""Run migrations in 'online' mode."""
|
|
||||||
asyncio.run(run_async_migrations())
|
|
||||||
|
|
||||||
if context.is_offline_mode():
|
|
||||||
run_migrations_offline()
|
|
||||||
else:
|
|
||||||
run_migrations_online()
|
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
"""Alembic environment configuration for tenant service"""
|
|
||||||
|
|
||||||
import asyncio
|
|
||||||
import logging
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
from logging.config import fileConfig
|
|
||||||
from sqlalchemy import pool
|
|
||||||
from sqlalchemy.engine import Connection
|
|
||||||
from sqlalchemy.ext.asyncio import async_engine_from_config
|
|
||||||
from alembic import context
|
|
||||||
|
|
||||||
# Add the service directory to the Python path
|
|
||||||
service_path = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
|
||||||
if service_path not in sys.path:
|
|
||||||
sys.path.insert(0, service_path)
|
|
||||||
|
|
||||||
# Add shared modules to path
|
|
||||||
shared_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "shared"))
|
|
||||||
if shared_path not in sys.path:
|
|
||||||
sys.path.insert(0, shared_path)
|
|
||||||
|
|
||||||
try:
|
|
||||||
from app.core.config import settings
|
|
||||||
from shared.database.base import Base
|
|
||||||
|
|
||||||
# Import all models to ensure they are registered with Base.metadata
|
|
||||||
from app.models import * # Import all models
|
|
||||||
|
|
||||||
except ImportError as e:
|
|
||||||
print(f"Import error in migrations env.py: {e}")
|
|
||||||
print(f"Current Python path: {sys.path}")
|
|
||||||
raise
|
|
||||||
|
|
||||||
# this is the Alembic Config object
|
|
||||||
config = context.config
|
|
||||||
|
|
||||||
# Set database URL from environment variables or settings
|
|
||||||
database_url = os.getenv('TENANT_DATABASE_URL') or os.getenv('DATABASE_URL')
|
|
||||||
|
|
||||||
# If DATABASE_URL is not set, construct from individual components
|
|
||||||
if not database_url:
|
|
||||||
postgres_host = os.getenv('POSTGRES_HOST')
|
|
||||||
postgres_port = os.getenv('POSTGRES_PORT', '5432')
|
|
||||||
postgres_db = os.getenv('POSTGRES_DB')
|
|
||||||
postgres_user = os.getenv('POSTGRES_USER')
|
|
||||||
postgres_password = os.getenv('POSTGRES_PASSWORD')
|
|
||||||
|
|
||||||
if all([postgres_host, postgres_db, postgres_user, postgres_password]):
|
|
||||||
database_url = f"postgresql+asyncpg://{postgres_user}:{postgres_password}@{postgres_host}:{postgres_port}/{postgres_db}"
|
|
||||||
else:
|
|
||||||
# Fallback to settings
|
|
||||||
database_url = getattr(settings, 'DATABASE_URL', None)
|
|
||||||
|
|
||||||
if database_url:
|
|
||||||
config.set_main_option("sqlalchemy.url", database_url)
|
|
||||||
|
|
||||||
# Interpret the config file for Python logging
|
|
||||||
if config.config_file_name is not None:
|
|
||||||
fileConfig(config.config_file_name)
|
|
||||||
|
|
||||||
# Set target metadata
|
|
||||||
target_metadata = Base.metadata
|
|
||||||
|
|
||||||
def run_migrations_offline() -> None:
|
|
||||||
"""Run migrations in 'offline' mode."""
|
|
||||||
url = config.get_main_option("sqlalchemy.url")
|
|
||||||
context.configure(
|
|
||||||
url=url,
|
|
||||||
target_metadata=target_metadata,
|
|
||||||
literal_binds=True,
|
|
||||||
dialect_opts={"paramstyle": "named"},
|
|
||||||
compare_type=True,
|
|
||||||
compare_server_default=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
with context.begin_transaction():
|
|
||||||
context.run_migrations()
|
|
||||||
|
|
||||||
def do_run_migrations(connection: Connection) -> None:
|
|
||||||
context.configure(
|
|
||||||
connection=connection,
|
|
||||||
target_metadata=target_metadata,
|
|
||||||
compare_type=True,
|
|
||||||
compare_server_default=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
with context.begin_transaction():
|
|
||||||
context.run_migrations()
|
|
||||||
|
|
||||||
async def run_async_migrations() -> None:
|
|
||||||
"""Run migrations in 'online' mode."""
|
|
||||||
connectable = async_engine_from_config(
|
|
||||||
config.get_section(config.config_ini_section, {}),
|
|
||||||
prefix="sqlalchemy.",
|
|
||||||
poolclass=pool.NullPool,
|
|
||||||
)
|
|
||||||
|
|
||||||
async with connectable.connect() as connection:
|
|
||||||
await connection.run_sync(do_run_migrations)
|
|
||||||
|
|
||||||
await connectable.dispose()
|
|
||||||
|
|
||||||
def run_migrations_online() -> None:
|
|
||||||
"""Run migrations in 'online' mode."""
|
|
||||||
asyncio.run(run_async_migrations())
|
|
||||||
|
|
||||||
if context.is_offline_mode():
|
|
||||||
run_migrations_offline()
|
|
||||||
else:
|
|
||||||
run_migrations_online()
|
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
"""Alembic environment configuration for training service"""
|
|
||||||
|
|
||||||
import asyncio
|
|
||||||
import logging
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
from logging.config import fileConfig
|
|
||||||
from sqlalchemy import pool
|
|
||||||
from sqlalchemy.engine import Connection
|
|
||||||
from sqlalchemy.ext.asyncio import async_engine_from_config
|
|
||||||
from alembic import context
|
|
||||||
|
|
||||||
# Add the service directory to the Python path
|
|
||||||
service_path = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
|
||||||
if service_path not in sys.path:
|
|
||||||
sys.path.insert(0, service_path)
|
|
||||||
|
|
||||||
# Add shared modules to path
|
|
||||||
shared_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "shared"))
|
|
||||||
if shared_path not in sys.path:
|
|
||||||
sys.path.insert(0, shared_path)
|
|
||||||
|
|
||||||
try:
|
|
||||||
from app.core.config import settings
|
|
||||||
from shared.database.base import Base
|
|
||||||
|
|
||||||
# Import all models to ensure they are registered with Base.metadata
|
|
||||||
from app.models import * # Import all models
|
|
||||||
|
|
||||||
except ImportError as e:
|
|
||||||
print(f"Import error in migrations env.py: {e}")
|
|
||||||
print(f"Current Python path: {sys.path}")
|
|
||||||
raise
|
|
||||||
|
|
||||||
# this is the Alembic Config object
|
|
||||||
config = context.config
|
|
||||||
|
|
||||||
# Set database URL from environment variables or settings
|
|
||||||
database_url = os.getenv('TRAINING_DATABASE_URL') or os.getenv('DATABASE_URL')
|
|
||||||
|
|
||||||
# If DATABASE_URL is not set, construct from individual components
|
|
||||||
if not database_url:
|
|
||||||
postgres_host = os.getenv('POSTGRES_HOST')
|
|
||||||
postgres_port = os.getenv('POSTGRES_PORT', '5432')
|
|
||||||
postgres_db = os.getenv('POSTGRES_DB')
|
|
||||||
postgres_user = os.getenv('POSTGRES_USER')
|
|
||||||
postgres_password = os.getenv('POSTGRES_PASSWORD')
|
|
||||||
|
|
||||||
if all([postgres_host, postgres_db, postgres_user, postgres_password]):
|
|
||||||
database_url = f"postgresql+asyncpg://{postgres_user}:{postgres_password}@{postgres_host}:{postgres_port}/{postgres_db}"
|
|
||||||
else:
|
|
||||||
# Fallback to settings
|
|
||||||
database_url = getattr(settings, 'DATABASE_URL', None)
|
|
||||||
|
|
||||||
if database_url:
|
|
||||||
config.set_main_option("sqlalchemy.url", database_url)
|
|
||||||
|
|
||||||
# Interpret the config file for Python logging
|
|
||||||
if config.config_file_name is not None:
|
|
||||||
fileConfig(config.config_file_name)
|
|
||||||
|
|
||||||
# Set target metadata
|
|
||||||
target_metadata = Base.metadata
|
|
||||||
|
|
||||||
def run_migrations_offline() -> None:
|
|
||||||
"""Run migrations in 'offline' mode."""
|
|
||||||
url = config.get_main_option("sqlalchemy.url")
|
|
||||||
context.configure(
|
|
||||||
url=url,
|
|
||||||
target_metadata=target_metadata,
|
|
||||||
literal_binds=True,
|
|
||||||
dialect_opts={"paramstyle": "named"},
|
|
||||||
compare_type=True,
|
|
||||||
compare_server_default=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
with context.begin_transaction():
|
|
||||||
context.run_migrations()
|
|
||||||
|
|
||||||
def do_run_migrations(connection: Connection) -> None:
|
|
||||||
context.configure(
|
|
||||||
connection=connection,
|
|
||||||
target_metadata=target_metadata,
|
|
||||||
compare_type=True,
|
|
||||||
compare_server_default=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
with context.begin_transaction():
|
|
||||||
context.run_migrations()
|
|
||||||
|
|
||||||
async def run_async_migrations() -> None:
|
|
||||||
"""Run migrations in 'online' mode."""
|
|
||||||
connectable = async_engine_from_config(
|
|
||||||
config.get_section(config.config_ini_section, {}),
|
|
||||||
prefix="sqlalchemy.",
|
|
||||||
poolclass=pool.NullPool,
|
|
||||||
)
|
|
||||||
|
|
||||||
async with connectable.connect() as connection:
|
|
||||||
await connection.run_sync(do_run_migrations)
|
|
||||||
|
|
||||||
await connectable.dispose()
|
|
||||||
|
|
||||||
def run_migrations_online() -> None:
|
|
||||||
"""Run migrations in 'online' mode."""
|
|
||||||
asyncio.run(run_async_migrations())
|
|
||||||
|
|
||||||
if context.is_offline_mode():
|
|
||||||
run_migrations_offline()
|
|
||||||
else:
|
|
||||||
run_migrations_online()
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
apiVersion: skaffold/v2beta28
|
apiVersion: skaffold/v2beta28
|
||||||
kind: Config
|
kind: Config
|
||||||
metadata:
|
metadata:
|
||||||
name: bakery-ia-local
|
name: bakery-ia
|
||||||
|
|
||||||
build:
|
build:
|
||||||
local:
|
local:
|
||||||
@@ -98,58 +98,24 @@ deploy:
|
|||||||
paths:
|
paths:
|
||||||
- infrastructure/kubernetes/overlays/dev
|
- infrastructure/kubernetes/overlays/dev
|
||||||
|
|
||||||
# Port forwarding removed - using ingress with direct port mapping
|
# Default deployment uses dev overlay
|
||||||
# Access via: https://localhost (or http://localhost)
|
# Access via ingress: http://localhost (or https://localhost)
|
||||||
|
#
|
||||||
|
# Available profiles:
|
||||||
|
# - dev: Local development (default)
|
||||||
|
# - debug: Local development with port forwarding for debugging
|
||||||
|
# - prod: Production deployment with production settings
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# skaffold dev # Uses default dev overlay
|
||||||
|
# skaffold dev -p dev # Explicitly use dev profile
|
||||||
|
# skaffold dev -p debug # Use debug profile with port forwarding
|
||||||
|
# skaffold run -p prod # Use prod profile for production
|
||||||
|
|
||||||
profiles:
|
profiles:
|
||||||
- name: minimal
|
|
||||||
build:
|
|
||||||
local:
|
|
||||||
push: false
|
|
||||||
tagPolicy:
|
|
||||||
envTemplate:
|
|
||||||
template: "dev"
|
|
||||||
deploy:
|
|
||||||
kubectl:
|
|
||||||
manifests:
|
|
||||||
- infrastructure/kubernetes/base/components/databases/auth-db.yaml
|
|
||||||
- infrastructure/kubernetes/base/components/databases/inventory-db.yaml
|
|
||||||
- infrastructure/kubernetes/base/migrations/auth-migration-job.yaml
|
|
||||||
- infrastructure/kubernetes/base/migrations/inventory-migration-job.yaml
|
|
||||||
- infrastructure/kubernetes/base/configs/*.yaml
|
|
||||||
|
|
||||||
- name: full
|
|
||||||
build:
|
|
||||||
local:
|
|
||||||
push: false
|
|
||||||
tagPolicy:
|
|
||||||
envTemplate:
|
|
||||||
template: "dev"
|
|
||||||
deploy:
|
|
||||||
kubectl:
|
|
||||||
manifests:
|
|
||||||
- infrastructure/kubernetes/base/components/databases/*.yaml
|
|
||||||
- infrastructure/kubernetes/base/migrations/*.yaml
|
|
||||||
- infrastructure/kubernetes/base/configs/*.yaml
|
|
||||||
kustomize:
|
|
||||||
paths:
|
|
||||||
- infrastructure/kubernetes/overlays/dev
|
|
||||||
|
|
||||||
- name: single
|
|
||||||
build:
|
|
||||||
local:
|
|
||||||
push: false
|
|
||||||
tagPolicy:
|
|
||||||
envTemplate:
|
|
||||||
template: "dev"
|
|
||||||
deploy:
|
|
||||||
kubectl:
|
|
||||||
manifests:
|
|
||||||
- infrastructure/kubernetes/base/components/databases/{{SERVICE_NAME}}.yaml
|
|
||||||
- infrastructure/kubernetes/base/migrations/{{SERVICE_NAME}}-migration-job.yaml
|
|
||||||
- infrastructure/kubernetes/base/configs/*.yaml
|
|
||||||
|
|
||||||
- name: dev
|
- name: dev
|
||||||
|
activation:
|
||||||
|
- command: dev
|
||||||
build:
|
build:
|
||||||
local:
|
local:
|
||||||
push: false
|
push: false
|
||||||
@@ -162,11 +128,14 @@ profiles:
|
|||||||
- infrastructure/kubernetes/overlays/dev
|
- infrastructure/kubernetes/overlays/dev
|
||||||
|
|
||||||
- name: debug
|
- name: debug
|
||||||
|
activation:
|
||||||
|
- command: debug
|
||||||
build:
|
build:
|
||||||
local:
|
local:
|
||||||
push: false
|
push: false
|
||||||
tagPolicy:
|
tagPolicy:
|
||||||
sha256: {}
|
envTemplate:
|
||||||
|
template: "dev"
|
||||||
deploy:
|
deploy:
|
||||||
kustomize:
|
kustomize:
|
||||||
paths:
|
paths:
|
||||||
@@ -187,3 +156,15 @@ profiles:
|
|||||||
namespace: bakery-ia
|
namespace: bakery-ia
|
||||||
port: 8000
|
port: 8000
|
||||||
localPort: 8001
|
localPort: 8001
|
||||||
|
|
||||||
|
- name: prod
|
||||||
|
build:
|
||||||
|
local:
|
||||||
|
push: false
|
||||||
|
tagPolicy:
|
||||||
|
gitCommit:
|
||||||
|
variant: AbbrevCommitSha
|
||||||
|
deploy:
|
||||||
|
kustomize:
|
||||||
|
paths:
|
||||||
|
- infrastructure/kubernetes/overlays/prod
|
||||||
Reference in New Issue
Block a user