From 147893015e61299fcf2b4ea8590d4ae208809a47 Mon Sep 17 00:00:00 2001 From: Urtzi Alfaro Date: Tue, 30 Sep 2025 13:32:51 +0200 Subject: [PATCH] Fix DB issues --- bakery-ia-ca.crt | 13 +++++ .../databases/alert-processor-db.yaml | 51 +++--------------- .../base/components/databases/auth-db.yaml | 52 +++---------------- .../components/databases/external-db.yaml | 51 +++--------------- .../components/databases/forecasting-db.yaml | 51 +++--------------- .../components/databases/inventory-db.yaml | 51 +++--------------- .../components/databases/notification-db.yaml | 51 +++--------------- .../base/components/databases/orders-db.yaml | 51 +++--------------- .../base/components/databases/pos-db.yaml | 51 +++--------------- .../components/databases/production-db.yaml | 51 +++--------------- .../base/components/databases/recipes-db.yaml | 51 +++--------------- .../base/components/databases/sales-db.yaml | 51 +++--------------- .../components/databases/suppliers-db.yaml | 51 +++--------------- .../base/components/databases/tenant-db.yaml | 52 +++---------------- .../components/databases/training-db.yaml | 51 +++--------------- infrastructure/kubernetes/base/secrets.yaml | 20 ++++++- services/alert_processor/Dockerfile | 7 +++ .../alert_processor/app/models/__init__.py | 16 +++++- .../001_initial_alert_processor_tables.py | 29 ----------- .../versions/001_initial_auth_tables.py | 29 ----------- services/external/Dockerfile | 4 ++ .../versions/001_initial_external_tables.py | 29 ----------- services/forecasting/Dockerfile | 3 ++ services/forecasting/app/models/__init__.py | 16 ++++++ .../migrations/versions/001_initial_tables.py | 28 ---------- services/inventory/Dockerfile | 4 ++ .../versions/001_initial_inventory_tables.py | 28 ---------- services/notification/Dockerfile | 3 ++ services/notification/app/models/__init__.py | 31 +++++++++++ .../001_initial_notification_tables.py | 29 ----------- services/orders/Dockerfile | 7 +++ services/orders/app/main.py | 10 ++-- services/orders/app/models/__init__.py | 21 ++++++++ .../versions/001_initial_orders_tables.py | 29 ----------- services/pos/Dockerfile | 7 +++ .../versions/001_initial_pos_tables.py | 28 ---------- services/production/Dockerfile | 7 +++ services/production/app/models/__init__.py | 20 +++++-- .../versions/001_initial_production_tables.py | 29 ----------- services/recipes/Dockerfile | 7 +++ .../versions/001_initial_recipe_tables.py | 29 ----------- services/sales/Dockerfile | 7 +++ .../versions/001_initial_sales_tables.py | 29 ----------- services/suppliers/Dockerfile | 7 +++ .../versions/001_initial_suppliers_tables.py | 29 ----------- services/tenant/Dockerfile | 3 ++ services/tenant/app/models/__init__.py | 15 ++++++ .../versions/001_initial_tenant_tables.py | 29 ----------- services/training/Dockerfile | 3 ++ services/training/app/models/__init__.py | 23 ++++++++ .../versions/001_initial_training_tables.py | 29 ----------- 51 files changed, 341 insertions(+), 1032 deletions(-) create mode 100644 bakery-ia-ca.crt delete mode 100644 services/alert_processor/migrations/versions/001_initial_alert_processor_tables.py delete mode 100644 services/auth/migrations/versions/001_initial_auth_tables.py delete mode 100644 services/external/migrations/versions/001_initial_external_tables.py delete mode 100644 services/forecasting/migrations/versions/001_initial_tables.py delete mode 100644 services/inventory/migrations/versions/001_initial_inventory_tables.py delete mode 100644 services/notification/migrations/versions/001_initial_notification_tables.py create mode 100644 services/orders/app/models/__init__.py delete mode 100644 services/orders/migrations/versions/001_initial_orders_tables.py delete mode 100644 services/pos/migrations/versions/001_initial_pos_tables.py delete mode 100644 services/production/migrations/versions/001_initial_production_tables.py delete mode 100644 services/recipes/migrations/versions/001_initial_recipe_tables.py delete mode 100644 services/sales/migrations/versions/001_initial_sales_tables.py delete mode 100644 services/suppliers/migrations/versions/001_initial_suppliers_tables.py delete mode 100644 services/tenant/migrations/versions/001_initial_tenant_tables.py delete mode 100644 services/training/migrations/versions/001_initial_training_tables.py diff --git a/bakery-ia-ca.crt b/bakery-ia-ca.crt new file mode 100644 index 00000000..a9e5a209 --- /dev/null +++ b/bakery-ia-ca.crt @@ -0,0 +1,13 @@ +-----BEGIN CERTIFICATE----- +MIIB9zCCAZ2gAwIBAgIRAI7sDPtvGTOEyP9+ob3PKD4wCgYIKoZIzj0EAwIwWzEL +MAkGA1UEBhMCVVMxEjAQBgNVBAoTCUJha2VyeSBJQTEbMBkGA1UECxMSQmFrZXJ5 +IElBIExvY2FsIENBMRswGQYDVQQDExJiYWtlcnktaWEtbG9jYWwtY2EwHhcNMjUw +OTMwMTA1NTAyWhcNMjYwOTMwMTA1NTAyWjBbMQswCQYDVQQGEwJVUzESMBAGA1UE +ChMJQmFrZXJ5IElBMRswGQYDVQQLExJCYWtlcnkgSUEgTG9jYWwgQ0ExGzAZBgNV +BAMTEmJha2VyeS1pYS1sb2NhbC1jYTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IA +BN1KZxIbllpM6asXLzkxmv58oIzEoqA6mnO/RsJTO3OupO6v2ndcP3QOVWAuaBZn +iKEe053LoVKiCI+Pa8UJ99ajQjBAMA4GA1UdDwEB/wQEAwICpDAPBgNVHRMBAf8E +BTADAQH/MB0GA1UdDgQWBBQinxdZ+q8nCCQ6a/hr2IJXqokLJDAKBggqhkjOPQQD +AgNIADBFAiA2ZRl4ohMOkVjcCWAOSHsAmlFsgow5Rn4A8nXtnv7fPwIhAIlsvohK +/exCO949h1xXK6FGyaNr40iXeFZkBeCy8oHW +-----END CERTIFICATE----- diff --git a/infrastructure/kubernetes/base/components/databases/alert-processor-db.yaml b/infrastructure/kubernetes/base/components/databases/alert-processor-db.yaml index 76e91cb8..3bb65e5a 100644 --- a/infrastructure/kubernetes/base/components/databases/alert-processor-db.yaml +++ b/infrastructure/kubernetes/base/components/databases/alert-processor-db.yaml @@ -1,19 +1,3 @@ -apiVersion: v1 -kind: PersistentVolume -metadata: - name: alert-processor-db-pv - labels: - app.kubernetes.io/component: database - app.kubernetes.io/part-of: bakery-ia -spec: - storageClassName: manual - capacity: - storage: 5Gi - accessModes: - - ReadWriteOnce - hostPath: - path: "/opt/bakery-data/alert-processor-db" ---- apiVersion: apps/v1 kind: Deployment metadata: @@ -79,11 +63,9 @@ spec: livenessProbe: exec: command: - - pg_isready - - -U - - $(POSTGRES_USER) - - -d - - $(POSTGRES_DB) + - sh + - -c + - pg_isready -U $POSTGRES_USER -d $POSTGRES_DB initialDelaySeconds: 30 timeoutSeconds: 5 periodSeconds: 10 @@ -91,19 +73,16 @@ spec: readinessProbe: exec: command: - - pg_isready - - -U - - $(POSTGRES_USER) - - -d - - $(POSTGRES_DB) + - sh + - -c + - pg_isready -U $POSTGRES_USER -d $POSTGRES_DB initialDelaySeconds: 5 timeoutSeconds: 1 periodSeconds: 5 failureThreshold: 3 volumes: - name: postgres-data - persistentVolumeClaim: - claimName: alert-processor-db-pvc + emptyDir: {} - name: init-scripts configMap: name: postgres-init-config @@ -128,19 +107,3 @@ spec: app.kubernetes.io/name: alert-processor-db app.kubernetes.io/component: database ---- -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: alert-processor-db-pvc - namespace: bakery-ia - labels: - app.kubernetes.io/name: alert-processor-db - app.kubernetes.io/component: database -spec: - storageClassName: manual - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 5Gi diff --git a/infrastructure/kubernetes/base/components/databases/auth-db.yaml b/infrastructure/kubernetes/base/components/databases/auth-db.yaml index 8a1fe5b4..6528232a 100644 --- a/infrastructure/kubernetes/base/components/databases/auth-db.yaml +++ b/infrastructure/kubernetes/base/components/databases/auth-db.yaml @@ -1,19 +1,3 @@ -apiVersion: v1 -kind: PersistentVolume -metadata: - name: auth-db-pv - labels: - app.kubernetes.io/component: database - app.kubernetes.io/part-of: bakery-ia -spec: - storageClassName: manual - capacity: - storage: 5Gi - accessModes: - - ReadWriteOnce - hostPath: - path: "/opt/bakery-data/auth-db" ---- apiVersion: apps/v1 kind: Deployment metadata: @@ -79,11 +63,9 @@ spec: livenessProbe: exec: command: - - pg_isready - - -U - - $(POSTGRES_USER) - - -d - - $(POSTGRES_DB) + - sh + - -c + - pg_isready -U $POSTGRES_USER -d $POSTGRES_DB initialDelaySeconds: 30 timeoutSeconds: 5 periodSeconds: 10 @@ -91,19 +73,16 @@ spec: readinessProbe: exec: command: - - pg_isready - - -U - - $(POSTGRES_USER) - - -d - - $(POSTGRES_DB) + - sh + - -c + - pg_isready -U $POSTGRES_USER -d $POSTGRES_DB initialDelaySeconds: 5 timeoutSeconds: 1 periodSeconds: 5 failureThreshold: 3 volumes: - name: postgres-data - persistentVolumeClaim: - claimName: auth-db-pvc + emptyDir: {} - name: init-scripts configMap: name: postgres-init-config @@ -127,20 +106,3 @@ spec: selector: app.kubernetes.io/name: auth-db app.kubernetes.io/component: database - ---- -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: auth-db-pvc - namespace: bakery-ia - labels: - app.kubernetes.io/name: auth-db - app.kubernetes.io/component: database -spec: - storageClassName: manual - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 5Gi diff --git a/infrastructure/kubernetes/base/components/databases/external-db.yaml b/infrastructure/kubernetes/base/components/databases/external-db.yaml index be1ac23a..a091b9a6 100644 --- a/infrastructure/kubernetes/base/components/databases/external-db.yaml +++ b/infrastructure/kubernetes/base/components/databases/external-db.yaml @@ -1,19 +1,3 @@ -apiVersion: v1 -kind: PersistentVolume -metadata: - name: external-db-pv - labels: - app.kubernetes.io/component: database - app.kubernetes.io/part-of: bakery-ia -spec: - storageClassName: manual - capacity: - storage: 5Gi - accessModes: - - ReadWriteOnce - hostPath: - path: "/opt/bakery-data/external-db" ---- apiVersion: apps/v1 kind: Deployment metadata: @@ -79,11 +63,9 @@ spec: livenessProbe: exec: command: - - pg_isready - - -U - - $(POSTGRES_USER) - - -d - - $(POSTGRES_DB) + - sh + - -c + - pg_isready -U $POSTGRES_USER -d $POSTGRES_DB initialDelaySeconds: 30 timeoutSeconds: 5 periodSeconds: 10 @@ -91,19 +73,16 @@ spec: readinessProbe: exec: command: - - pg_isready - - -U - - $(POSTGRES_USER) - - -d - - $(POSTGRES_DB) + - sh + - -c + - pg_isready -U $POSTGRES_USER -d $POSTGRES_DB initialDelaySeconds: 5 timeoutSeconds: 1 periodSeconds: 5 failureThreshold: 3 volumes: - name: postgres-data - persistentVolumeClaim: - claimName: external-db-pvc + emptyDir: {} - name: init-scripts configMap: name: postgres-init-config @@ -128,19 +107,3 @@ spec: app.kubernetes.io/name: external-db app.kubernetes.io/component: database ---- -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: external-db-pvc - namespace: bakery-ia - labels: - app.kubernetes.io/name: external-db - app.kubernetes.io/component: database -spec: - storageClassName: manual - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 5Gi diff --git a/infrastructure/kubernetes/base/components/databases/forecasting-db.yaml b/infrastructure/kubernetes/base/components/databases/forecasting-db.yaml index af511fba..069a854d 100644 --- a/infrastructure/kubernetes/base/components/databases/forecasting-db.yaml +++ b/infrastructure/kubernetes/base/components/databases/forecasting-db.yaml @@ -1,19 +1,3 @@ -apiVersion: v1 -kind: PersistentVolume -metadata: - name: forecasting-db-pv - labels: - app.kubernetes.io/component: database - app.kubernetes.io/part-of: bakery-ia -spec: - storageClassName: manual - capacity: - storage: 5Gi - accessModes: - - ReadWriteOnce - hostPath: - path: "/opt/bakery-data/forecasting-db" ---- apiVersion: apps/v1 kind: Deployment metadata: @@ -79,11 +63,9 @@ spec: livenessProbe: exec: command: - - pg_isready - - -U - - $(POSTGRES_USER) - - -d - - $(POSTGRES_DB) + - sh + - -c + - pg_isready -U $POSTGRES_USER -d $POSTGRES_DB initialDelaySeconds: 30 timeoutSeconds: 5 periodSeconds: 10 @@ -91,19 +73,16 @@ spec: readinessProbe: exec: command: - - pg_isready - - -U - - $(POSTGRES_USER) - - -d - - $(POSTGRES_DB) + - sh + - -c + - pg_isready -U $POSTGRES_USER -d $POSTGRES_DB initialDelaySeconds: 5 timeoutSeconds: 1 periodSeconds: 5 failureThreshold: 3 volumes: - name: postgres-data - persistentVolumeClaim: - claimName: forecasting-db-pvc + emptyDir: {} - name: init-scripts configMap: name: postgres-init-config @@ -128,19 +107,3 @@ spec: app.kubernetes.io/name: forecasting-db app.kubernetes.io/component: database ---- -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: forecasting-db-pvc - namespace: bakery-ia - labels: - app.kubernetes.io/name: forecasting-db - app.kubernetes.io/component: database -spec: - storageClassName: manual - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 5Gi diff --git a/infrastructure/kubernetes/base/components/databases/inventory-db.yaml b/infrastructure/kubernetes/base/components/databases/inventory-db.yaml index 06eb141b..f7f110fb 100644 --- a/infrastructure/kubernetes/base/components/databases/inventory-db.yaml +++ b/infrastructure/kubernetes/base/components/databases/inventory-db.yaml @@ -1,19 +1,3 @@ -apiVersion: v1 -kind: PersistentVolume -metadata: - name: inventory-db-pv - labels: - app.kubernetes.io/component: database - app.kubernetes.io/part-of: bakery-ia -spec: - storageClassName: manual - capacity: - storage: 5Gi - accessModes: - - ReadWriteOnce - hostPath: - path: "/opt/bakery-data/inventory-db" ---- apiVersion: apps/v1 kind: Deployment metadata: @@ -79,11 +63,9 @@ spec: livenessProbe: exec: command: - - pg_isready - - -U - - $(POSTGRES_USER) - - -d - - $(POSTGRES_DB) + - sh + - -c + - pg_isready -U $POSTGRES_USER -d $POSTGRES_DB initialDelaySeconds: 30 timeoutSeconds: 5 periodSeconds: 10 @@ -91,19 +73,16 @@ spec: readinessProbe: exec: command: - - pg_isready - - -U - - $(POSTGRES_USER) - - -d - - $(POSTGRES_DB) + - sh + - -c + - pg_isready -U $POSTGRES_USER -d $POSTGRES_DB initialDelaySeconds: 5 timeoutSeconds: 1 periodSeconds: 5 failureThreshold: 3 volumes: - name: postgres-data - persistentVolumeClaim: - claimName: inventory-db-pvc + emptyDir: {} - name: init-scripts configMap: name: postgres-init-config @@ -128,19 +107,3 @@ spec: app.kubernetes.io/name: inventory-db app.kubernetes.io/component: database ---- -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: inventory-db-pvc - namespace: bakery-ia - labels: - app.kubernetes.io/name: inventory-db - app.kubernetes.io/component: database -spec: - storageClassName: manual - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 5Gi diff --git a/infrastructure/kubernetes/base/components/databases/notification-db.yaml b/infrastructure/kubernetes/base/components/databases/notification-db.yaml index ce04ca04..c9cc013d 100644 --- a/infrastructure/kubernetes/base/components/databases/notification-db.yaml +++ b/infrastructure/kubernetes/base/components/databases/notification-db.yaml @@ -1,19 +1,3 @@ -apiVersion: v1 -kind: PersistentVolume -metadata: - name: notification-db-pv - labels: - app.kubernetes.io/component: database - app.kubernetes.io/part-of: bakery-ia -spec: - storageClassName: manual - capacity: - storage: 5Gi - accessModes: - - ReadWriteOnce - hostPath: - path: "/opt/bakery-data/notification-db" ---- apiVersion: apps/v1 kind: Deployment metadata: @@ -79,11 +63,9 @@ spec: livenessProbe: exec: command: - - pg_isready - - -U - - $(POSTGRES_USER) - - -d - - $(POSTGRES_DB) + - sh + - -c + - pg_isready -U $POSTGRES_USER -d $POSTGRES_DB initialDelaySeconds: 30 timeoutSeconds: 5 periodSeconds: 10 @@ -91,19 +73,16 @@ spec: readinessProbe: exec: command: - - pg_isready - - -U - - $(POSTGRES_USER) - - -d - - $(POSTGRES_DB) + - sh + - -c + - pg_isready -U $POSTGRES_USER -d $POSTGRES_DB initialDelaySeconds: 5 timeoutSeconds: 1 periodSeconds: 5 failureThreshold: 3 volumes: - name: postgres-data - persistentVolumeClaim: - claimName: notification-db-pvc + emptyDir: {} - name: init-scripts configMap: name: postgres-init-config @@ -128,19 +107,3 @@ spec: app.kubernetes.io/name: notification-db app.kubernetes.io/component: database ---- -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: notification-db-pvc - namespace: bakery-ia - labels: - app.kubernetes.io/name: notification-db - app.kubernetes.io/component: database -spec: - storageClassName: manual - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 5Gi diff --git a/infrastructure/kubernetes/base/components/databases/orders-db.yaml b/infrastructure/kubernetes/base/components/databases/orders-db.yaml index b31e2035..1a2931fe 100644 --- a/infrastructure/kubernetes/base/components/databases/orders-db.yaml +++ b/infrastructure/kubernetes/base/components/databases/orders-db.yaml @@ -1,19 +1,3 @@ -apiVersion: v1 -kind: PersistentVolume -metadata: - name: orders-db-pv - labels: - app.kubernetes.io/component: database - app.kubernetes.io/part-of: bakery-ia -spec: - storageClassName: manual - capacity: - storage: 5Gi - accessModes: - - ReadWriteOnce - hostPath: - path: "/opt/bakery-data/orders-db" ---- apiVersion: apps/v1 kind: Deployment metadata: @@ -79,11 +63,9 @@ spec: livenessProbe: exec: command: - - pg_isready - - -U - - $(POSTGRES_USER) - - -d - - $(POSTGRES_DB) + - sh + - -c + - pg_isready -U $POSTGRES_USER -d $POSTGRES_DB initialDelaySeconds: 30 timeoutSeconds: 5 periodSeconds: 10 @@ -91,19 +73,16 @@ spec: readinessProbe: exec: command: - - pg_isready - - -U - - $(POSTGRES_USER) - - -d - - $(POSTGRES_DB) + - sh + - -c + - pg_isready -U $POSTGRES_USER -d $POSTGRES_DB initialDelaySeconds: 5 timeoutSeconds: 1 periodSeconds: 5 failureThreshold: 3 volumes: - name: postgres-data - persistentVolumeClaim: - claimName: orders-db-pvc + emptyDir: {} - name: init-scripts configMap: name: postgres-init-config @@ -128,19 +107,3 @@ spec: app.kubernetes.io/name: orders-db app.kubernetes.io/component: database ---- -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: orders-db-pvc - namespace: bakery-ia - labels: - app.kubernetes.io/name: orders-db - app.kubernetes.io/component: database -spec: - storageClassName: manual - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 5Gi diff --git a/infrastructure/kubernetes/base/components/databases/pos-db.yaml b/infrastructure/kubernetes/base/components/databases/pos-db.yaml index ad5fa00d..dff8ca1a 100644 --- a/infrastructure/kubernetes/base/components/databases/pos-db.yaml +++ b/infrastructure/kubernetes/base/components/databases/pos-db.yaml @@ -1,19 +1,3 @@ -apiVersion: v1 -kind: PersistentVolume -metadata: - name: pos-db-pv - labels: - app.kubernetes.io/component: database - app.kubernetes.io/part-of: bakery-ia -spec: - storageClassName: manual - capacity: - storage: 5Gi - accessModes: - - ReadWriteOnce - hostPath: - path: "/opt/bakery-data/pos-db" ---- apiVersion: apps/v1 kind: Deployment metadata: @@ -79,11 +63,9 @@ spec: livenessProbe: exec: command: - - pg_isready - - -U - - $(POSTGRES_USER) - - -d - - $(POSTGRES_DB) + - sh + - -c + - pg_isready -U $POSTGRES_USER -d $POSTGRES_DB initialDelaySeconds: 30 timeoutSeconds: 5 periodSeconds: 10 @@ -91,19 +73,16 @@ spec: readinessProbe: exec: command: - - pg_isready - - -U - - $(POSTGRES_USER) - - -d - - $(POSTGRES_DB) + - sh + - -c + - pg_isready -U $POSTGRES_USER -d $POSTGRES_DB initialDelaySeconds: 5 timeoutSeconds: 1 periodSeconds: 5 failureThreshold: 3 volumes: - name: postgres-data - persistentVolumeClaim: - claimName: pos-db-pvc + emptyDir: {} - name: init-scripts configMap: name: postgres-init-config @@ -128,19 +107,3 @@ spec: app.kubernetes.io/name: pos-db app.kubernetes.io/component: database ---- -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: pos-db-pvc - namespace: bakery-ia - labels: - app.kubernetes.io/name: pos-db - app.kubernetes.io/component: database -spec: - storageClassName: manual - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 5Gi diff --git a/infrastructure/kubernetes/base/components/databases/production-db.yaml b/infrastructure/kubernetes/base/components/databases/production-db.yaml index a5c1eef9..f22776b9 100644 --- a/infrastructure/kubernetes/base/components/databases/production-db.yaml +++ b/infrastructure/kubernetes/base/components/databases/production-db.yaml @@ -1,19 +1,3 @@ -apiVersion: v1 -kind: PersistentVolume -metadata: - name: production-db-pv - labels: - app.kubernetes.io/component: database - app.kubernetes.io/part-of: bakery-ia -spec: - storageClassName: manual - capacity: - storage: 5Gi - accessModes: - - ReadWriteOnce - hostPath: - path: "/opt/bakery-data/production-db" ---- apiVersion: apps/v1 kind: Deployment metadata: @@ -79,11 +63,9 @@ spec: livenessProbe: exec: command: - - pg_isready - - -U - - $(POSTGRES_USER) - - -d - - $(POSTGRES_DB) + - sh + - -c + - pg_isready -U $POSTGRES_USER -d $POSTGRES_DB initialDelaySeconds: 30 timeoutSeconds: 5 periodSeconds: 10 @@ -91,19 +73,16 @@ spec: readinessProbe: exec: command: - - pg_isready - - -U - - $(POSTGRES_USER) - - -d - - $(POSTGRES_DB) + - sh + - -c + - pg_isready -U $POSTGRES_USER -d $POSTGRES_DB initialDelaySeconds: 5 timeoutSeconds: 1 periodSeconds: 5 failureThreshold: 3 volumes: - name: postgres-data - persistentVolumeClaim: - claimName: production-db-pvc + emptyDir: {} - name: init-scripts configMap: name: postgres-init-config @@ -128,19 +107,3 @@ spec: app.kubernetes.io/name: production-db app.kubernetes.io/component: database ---- -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: production-db-pvc - namespace: bakery-ia - labels: - app.kubernetes.io/name: production-db - app.kubernetes.io/component: database -spec: - storageClassName: manual - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 5Gi diff --git a/infrastructure/kubernetes/base/components/databases/recipes-db.yaml b/infrastructure/kubernetes/base/components/databases/recipes-db.yaml index ca7a9914..3983ab30 100644 --- a/infrastructure/kubernetes/base/components/databases/recipes-db.yaml +++ b/infrastructure/kubernetes/base/components/databases/recipes-db.yaml @@ -1,19 +1,3 @@ -apiVersion: v1 -kind: PersistentVolume -metadata: - name: recipes-db-pv - labels: - app.kubernetes.io/component: database - app.kubernetes.io/part-of: bakery-ia -spec: - storageClassName: manual - capacity: - storage: 5Gi - accessModes: - - ReadWriteOnce - hostPath: - path: "/opt/bakery-data/recipes-db" ---- apiVersion: apps/v1 kind: Deployment metadata: @@ -79,11 +63,9 @@ spec: livenessProbe: exec: command: - - pg_isready - - -U - - $(POSTGRES_USER) - - -d - - $(POSTGRES_DB) + - sh + - -c + - pg_isready -U $POSTGRES_USER -d $POSTGRES_DB initialDelaySeconds: 30 timeoutSeconds: 5 periodSeconds: 10 @@ -91,19 +73,16 @@ spec: readinessProbe: exec: command: - - pg_isready - - -U - - $(POSTGRES_USER) - - -d - - $(POSTGRES_DB) + - sh + - -c + - pg_isready -U $POSTGRES_USER -d $POSTGRES_DB initialDelaySeconds: 5 timeoutSeconds: 1 periodSeconds: 5 failureThreshold: 3 volumes: - name: postgres-data - persistentVolumeClaim: - claimName: recipes-db-pvc + emptyDir: {} - name: init-scripts configMap: name: postgres-init-config @@ -128,19 +107,3 @@ spec: app.kubernetes.io/name: recipes-db app.kubernetes.io/component: database ---- -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: recipes-db-pvc - namespace: bakery-ia - labels: - app.kubernetes.io/name: recipes-db - app.kubernetes.io/component: database -spec: - storageClassName: manual - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 5Gi diff --git a/infrastructure/kubernetes/base/components/databases/sales-db.yaml b/infrastructure/kubernetes/base/components/databases/sales-db.yaml index 25bb846b..bf2071b4 100644 --- a/infrastructure/kubernetes/base/components/databases/sales-db.yaml +++ b/infrastructure/kubernetes/base/components/databases/sales-db.yaml @@ -1,19 +1,3 @@ -apiVersion: v1 -kind: PersistentVolume -metadata: - name: sales-db-pv - labels: - app.kubernetes.io/component: database - app.kubernetes.io/part-of: bakery-ia -spec: - storageClassName: manual - capacity: - storage: 5Gi - accessModes: - - ReadWriteOnce - hostPath: - path: "/opt/bakery-data/sales-db" ---- apiVersion: apps/v1 kind: Deployment metadata: @@ -79,11 +63,9 @@ spec: livenessProbe: exec: command: - - pg_isready - - -U - - $(POSTGRES_USER) - - -d - - $(POSTGRES_DB) + - sh + - -c + - pg_isready -U $POSTGRES_USER -d $POSTGRES_DB initialDelaySeconds: 30 timeoutSeconds: 5 periodSeconds: 10 @@ -91,19 +73,16 @@ spec: readinessProbe: exec: command: - - pg_isready - - -U - - $(POSTGRES_USER) - - -d - - $(POSTGRES_DB) + - sh + - -c + - pg_isready -U $POSTGRES_USER -d $POSTGRES_DB initialDelaySeconds: 5 timeoutSeconds: 1 periodSeconds: 5 failureThreshold: 3 volumes: - name: postgres-data - persistentVolumeClaim: - claimName: sales-db-pvc + emptyDir: {} - name: init-scripts configMap: name: postgres-init-config @@ -128,19 +107,3 @@ spec: app.kubernetes.io/name: sales-db app.kubernetes.io/component: database ---- -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: sales-db-pvc - namespace: bakery-ia - labels: - app.kubernetes.io/name: sales-db - app.kubernetes.io/component: database -spec: - storageClassName: manual - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 5Gi diff --git a/infrastructure/kubernetes/base/components/databases/suppliers-db.yaml b/infrastructure/kubernetes/base/components/databases/suppliers-db.yaml index ba7f3ae4..584020b4 100644 --- a/infrastructure/kubernetes/base/components/databases/suppliers-db.yaml +++ b/infrastructure/kubernetes/base/components/databases/suppliers-db.yaml @@ -1,19 +1,3 @@ -apiVersion: v1 -kind: PersistentVolume -metadata: - name: suppliers-db-pv - labels: - app.kubernetes.io/component: database - app.kubernetes.io/part-of: bakery-ia -spec: - storageClassName: manual - capacity: - storage: 5Gi - accessModes: - - ReadWriteOnce - hostPath: - path: "/opt/bakery-data/suppliers-db" ---- apiVersion: apps/v1 kind: Deployment metadata: @@ -79,11 +63,9 @@ spec: livenessProbe: exec: command: - - pg_isready - - -U - - $(POSTGRES_USER) - - -d - - $(POSTGRES_DB) + - sh + - -c + - pg_isready -U $POSTGRES_USER -d $POSTGRES_DB initialDelaySeconds: 30 timeoutSeconds: 5 periodSeconds: 10 @@ -91,19 +73,16 @@ spec: readinessProbe: exec: command: - - pg_isready - - -U - - $(POSTGRES_USER) - - -d - - $(POSTGRES_DB) + - sh + - -c + - pg_isready -U $POSTGRES_USER -d $POSTGRES_DB initialDelaySeconds: 5 timeoutSeconds: 1 periodSeconds: 5 failureThreshold: 3 volumes: - name: postgres-data - persistentVolumeClaim: - claimName: suppliers-db-pvc + emptyDir: {} - name: init-scripts configMap: name: postgres-init-config @@ -128,19 +107,3 @@ spec: app.kubernetes.io/name: suppliers-db app.kubernetes.io/component: database ---- -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: suppliers-db-pvc - namespace: bakery-ia - labels: - app.kubernetes.io/name: suppliers-db - app.kubernetes.io/component: database -spec: - storageClassName: manual - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 5Gi diff --git a/infrastructure/kubernetes/base/components/databases/tenant-db.yaml b/infrastructure/kubernetes/base/components/databases/tenant-db.yaml index 88ad0eba..9508afd1 100644 --- a/infrastructure/kubernetes/base/components/databases/tenant-db.yaml +++ b/infrastructure/kubernetes/base/components/databases/tenant-db.yaml @@ -1,19 +1,3 @@ -apiVersion: v1 -kind: PersistentVolume -metadata: - name: tenant-db-pv - labels: - app.kubernetes.io/component: database - app.kubernetes.io/part-of: bakery-ia -spec: - storageClassName: manual - capacity: - storage: 5Gi - accessModes: - - ReadWriteOnce - hostPath: - path: "/opt/bakery-data/tenant-db" ---- apiVersion: apps/v1 kind: Deployment metadata: @@ -79,11 +63,9 @@ spec: livenessProbe: exec: command: - - pg_isready - - -U - - $(POSTGRES_USER) - - -d - - $(POSTGRES_DB) + - sh + - -c + - pg_isready -U $POSTGRES_USER -d $POSTGRES_DB initialDelaySeconds: 30 timeoutSeconds: 5 periodSeconds: 10 @@ -91,19 +73,16 @@ spec: readinessProbe: exec: command: - - pg_isready - - -U - - $(POSTGRES_USER) - - -d - - $(POSTGRES_DB) + - sh + - -c + - pg_isready -U $POSTGRES_USER -d $POSTGRES_DB initialDelaySeconds: 5 timeoutSeconds: 1 periodSeconds: 5 failureThreshold: 3 volumes: - name: postgres-data - persistentVolumeClaim: - claimName: tenant-db-pvc + emptyDir: {} - name: init-scripts configMap: name: postgres-init-config @@ -127,20 +106,3 @@ spec: selector: app.kubernetes.io/name: tenant-db app.kubernetes.io/component: database - ---- -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: tenant-db-pvc - namespace: bakery-ia - labels: - app.kubernetes.io/name: tenant-db - app.kubernetes.io/component: database -spec: - storageClassName: manual - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 5Gi diff --git a/infrastructure/kubernetes/base/components/databases/training-db.yaml b/infrastructure/kubernetes/base/components/databases/training-db.yaml index abd82a53..a345e725 100644 --- a/infrastructure/kubernetes/base/components/databases/training-db.yaml +++ b/infrastructure/kubernetes/base/components/databases/training-db.yaml @@ -1,19 +1,3 @@ -apiVersion: v1 -kind: PersistentVolume -metadata: - name: training-db-pv - labels: - app.kubernetes.io/component: database - app.kubernetes.io/part-of: bakery-ia -spec: - storageClassName: manual - capacity: - storage: 5Gi - accessModes: - - ReadWriteOnce - hostPath: - path: "/opt/bakery-data/training-db" ---- apiVersion: apps/v1 kind: Deployment metadata: @@ -79,11 +63,9 @@ spec: livenessProbe: exec: command: - - pg_isready - - -U - - $(POSTGRES_USER) - - -d - - $(POSTGRES_DB) + - sh + - -c + - pg_isready -U $POSTGRES_USER -d $POSTGRES_DB initialDelaySeconds: 30 timeoutSeconds: 5 periodSeconds: 10 @@ -91,19 +73,16 @@ spec: readinessProbe: exec: command: - - pg_isready - - -U - - $(POSTGRES_USER) - - -d - - $(POSTGRES_DB) + - sh + - -c + - pg_isready -U $POSTGRES_USER -d $POSTGRES_DB initialDelaySeconds: 5 timeoutSeconds: 1 periodSeconds: 5 failureThreshold: 3 volumes: - name: postgres-data - persistentVolumeClaim: - claimName: training-db-pvc + emptyDir: {} - name: init-scripts configMap: name: postgres-init-config @@ -128,19 +107,3 @@ spec: app.kubernetes.io/name: training-db app.kubernetes.io/component: database ---- -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: training-db-pvc - namespace: bakery-ia - labels: - app.kubernetes.io/name: training-db - app.kubernetes.io/component: database -spec: - storageClassName: manual - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 5Gi diff --git a/infrastructure/kubernetes/base/secrets.yaml b/infrastructure/kubernetes/base/secrets.yaml index 2996a1c9..2f39ae27 100644 --- a/infrastructure/kubernetes/base/secrets.yaml +++ b/infrastructure/kubernetes/base/secrets.yaml @@ -25,7 +25,7 @@ data: ALERT_PROCESSOR_DB_USER: YWxlcnRfcHJvY2Vzc29yX3VzZXI= # alert_processor_user # Database Passwords (base64 encoded from .env) - AUTH_DB_PASSWORD: YXV0aF9wYXNzMTIz # auth_pass123 + AUTH_DB_PASSWORD: YXV0aF9wYXNzMTIz # auth_pass123 TENANT_DB_PASSWORD: dGVuYW50X3Bhc3MxMjM= # tenant_pass123 TRAINING_DB_PASSWORD: dHJhaW5pbmdfcGFzczEyMw== # training_pass123 FORECASTING_DB_PASSWORD: Zm9yZWNhc3RpbmdfcGFzczEyMw== # forecasting_pass123 @@ -40,6 +40,22 @@ data: PRODUCTION_DB_PASSWORD: cHJvZHVjdGlvbl9wYXNzMTIz # production_pass123 ALERT_PROCESSOR_DB_PASSWORD: YWxlcnRfcHJvY2Vzc29yX3Bhc3MxMjM= # alert_processor_pass123 + # Database URLs (base64 encoded) + AUTH_DATABASE_URL: cG9zdGdyZXNxbCthc3luY3BnOi8vYXV0aF91c2VyOmF1dGhfcGFzczEyM0BhdXRoLWRiLXNlcnZpY2U6NTQzMi9hdXRoX2Ri # postgresql+asyncpg://auth_user:auth_pass123@auth-db-service:5432/auth_db + TENANT_DATABASE_URL: cG9zdGdyZXNxbCthc3luY3BnOi8vdGVuYW50X3VzZXI6dGVuYW50X3Bhc3MxMjNAdGVuYW50LWRiLXNlcnZpY2U6NTQzMi90ZW5hbnRfZGIK # postgresql+asyncpg://tenant_user:tenant_pass123@tenant-db-service:5432/tenant_db + TRAINING_DATABASE_URL: cG9zdGdyZXNxbCthc3luY3BnOi8vdHJhaW5pbmdfdXNlcjp0cmFpbmluZ19wYXNzMTIzQHRyYWluaW5nLWRiLXNlcnZpY2U6NTQzMi90cmFpbmluZ19kYg== # postgresql+asyncpg://training_user:training_pass123@training-db-service:5432/training_db + FORECASTING_DATABASE_URL: cG9zdGdyZXNxbCthc3luY3BnOi8vZm9yZWNhc3RpbmdfdXNlcjpmb3JlY2FzdGluZ19wYXNzMTIzQGZvcmVjYXN0aW5nLWRiLXNlcnZpY2U6NTQzMi9mb3JlY2FzdGluZ19kYg== # postgresql+asyncpg://forecasting_user:forecasting_pass123@forecasting-db-service:5432/forecasting_db + SALES_DATABASE_URL: cG9zdGdyZXNxbCthc3luY3BnOi8vc2FsZXNfdXNlcjpzYWxlc19wYXNzMTIzQHNhbGVzLWRiLXNlcnZpY2U6NTQzMi9zYWxlc19kYg== # postgresql+asyncpg://sales_user:sales_pass123@sales-db-service:5432/sales_db + EXTERNAL_DATABASE_URL: cG9zdGdyZXNxbCthc3luY3BnOi8vZXh0ZXJuYWxfdXNlcjpleHRlcm5hbF9wYXNzMTIzQGV4dGVybmFsLWRiLXNlcnZpY2U6NTQzMi9leHRlcm5hbF9kYg== # postgresql+asyncpg://external_user:external_pass123@external-db-service:5432/external_db + NOTIFICATION_DATABASE_URL: cG9zdGdyZXNxbCthc3luY3BnOi8vbm90aWZpY2F0aW9uX3VzZXI6bm90aWZpY2F0aW9uX3Bhc3MxMjNAbm90aWZpY2F0aW9uLWRiLXNlcnZpY2U6NTQzMi9ub3RpZmljYXRpb25fZGI= # postgresql+asyncpg://notification_user:notification_pass123@notification-db-service:5432/notification_db + INVENTORY_DATABASE_URL: cG9zdGdyZXNxbCthc3luY3BnOi8vaW52ZW50b3J5X3VzZXI6aW52ZW50b3J5X3Bhc3MxMjNAaW52ZW50b3J5LWRiLXNlcnZpY2U6NTQzMi9pbnZlbnRvcnlfZGI= # postgresql+asyncpg://inventory_user:inventory_pass123@inventory-db-service:5432/inventory_db + RECIPES_DATABASE_URL: cG9zdGdyZXNxbCthc3luY3BnOi8vcmVjaXBlc191c2VyOnJlY2lwZXNfcGFzczEyM0ByZWNpcGVzLWRiLXNlcnZpY2U6NTQzMi9yZWNpcGVzX2Ri # postgresql+asyncpg://recipes_user:recipes_pass123@recipes-db-service:5432/recipes_db + SUPPLIERS_DATABASE_URL: cG9zdGdyZXNxbCthc3luY3BnOi8vc3VwcGxpZXJzX3VzZXI6c3VwcGxpZXJzX3Bhc3MxMjNAc3VwcGxpZXJzLWRiLXNlcnZpY2U6NTQzMi9zdXBwbGllcnNfZGI= # postgresql+asyncpg://suppliers_user:suppliers_pass123@suppliers-db-service:5432/suppliers_db + POS_DATABASE_URL: cG9zdGdyZXNxbCthc3luY3BnOi8vcG9zX3VzZXI6cG9zX3Bhc3MxMjNAcG9zLWRiLXNlcnZpY2U6NTQzMi9wb3NfZGI= # postgresql+asyncpg://pos_user:pos_pass123@pos-db-service:5432/pos_db + ORDERS_DATABASE_URL: cG9zdGdyZXNxbCthc3luY3BnOi8vb3JkZXJzX3VzZXI6b3JkZXJzX3Bhc3MxMjNAb3JkZXJzLWRiLXNlcnZpY2U6NTQzMi9vcmRlcnNfZGI= # postgresql+asyncpg://orders_user:orders_pass123@orders-db-service:5432/orders_db + PRODUCTION_DATABASE_URL: cG9zdGdyZXNxbCthc3luY3BnOi8vcHJvZHVjdGlvbl91c2VyOnByb2R1Y3Rpb25fcGFzczEyM0Bwcm9kdWN0aW9uLWRiLXNlcnZpY2U6NTQzMi9wcm9kdWN0aW9uX2Ri # postgresql+asyncpg://production_user:production_pass123@production-db-service:5432/production_db + ALERT_PROCESSOR_DATABASE_URL: cG9zdGdyZXNxbCthc3luY3BnOi8vYWxlcnRfcHJvY2Vzc29yX3VzZXI6YWxlcnRfcHJvY2Vzc29yX3Bhc3MxMjNAYWxlcnQtcHJvY2Vzc29yLWRiLXNlcnZpY2U6NTQzMi9hbGVydF9wcm9jZXNzb3JfZGI= # postgresql+asyncpg://alert_processor_user:alert_processor_pass123@alert-processor-db-service:5432/alert_processor_db + --- apiVersion: v1 kind: Secret @@ -175,4 +191,4 @@ metadata: app.kubernetes.io/component: notifications type: Opaque data: - WHATSAPP_API_KEY: eW91ci13aGF0c2FwcC1hcGkta2V5LWhlcmU= # your-whatsapp-api-key-here \ No newline at end of file + WHATSAPP_API_KEY: eW91ci13aGF0c2FwcC1hcGkta2V5LWhlcmU= # your-whatsapp-api-key-here diff --git a/services/alert_processor/Dockerfile b/services/alert_processor/Dockerfile index 207e0005..ce8adc9a 100644 --- a/services/alert_processor/Dockerfile +++ b/services/alert_processor/Dockerfile @@ -17,6 +17,13 @@ COPY shared/ /app/shared/ # Copy application code COPY services/alert_processor/app/ /app/app/ +# Copy migrations and alembic config +COPY services/alert_processor/migrations/ /app/migrations/ +COPY services/alert_processor/alembic.ini /app/alembic.ini + +# Copy scripts directory +COPY scripts/ /app/scripts/ + # Create non-root user RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app USER appuser diff --git a/services/alert_processor/app/models/__init__.py b/services/alert_processor/app/models/__init__.py index 99940351..bb085013 100644 --- a/services/alert_processor/app/models/__init__.py +++ b/services/alert_processor/app/models/__init__.py @@ -1 +1,15 @@ -# services/alert_processor/app/models/__init__.py \ No newline at end of file +""" +Alert Processor Service Models Package + +Import all models to ensure they are registered with SQLAlchemy Base. +""" + +# Import all models to register them with the Base metadata +from .alerts import Alert, AlertStatus, AlertSeverity + +# List all models for easier access +__all__ = [ + "Alert", + "AlertStatus", + "AlertSeverity", +] \ No newline at end of file diff --git a/services/alert_processor/migrations/versions/001_initial_alert_processor_tables.py b/services/alert_processor/migrations/versions/001_initial_alert_processor_tables.py deleted file mode 100644 index 747e8de9..00000000 --- a/services/alert_processor/migrations/versions/001_initial_alert_processor_tables.py +++ /dev/null @@ -1,29 +0,0 @@ -"""Initial alert-processor service tables - -Revision ID: 001_initial_alert_processor -Revises: -Create Date: 2024-01-01 12:00:00.000000 - -""" -from typing import Sequence, Union - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision: str = '001_initial_alert_processor' -down_revision: Union[str, None] = None -branch_labels: Union[str, Sequence[str], None] = None -depends_on: Union[str, Sequence[str], None] = None - - -def upgrade() -> None: - # TODO: Add table creation statements for alert_processor service - # This is a placeholder migration - replace with actual table definitions - pass - - -def downgrade() -> None: - # TODO: Add table drop statements for alert_processor service - pass diff --git a/services/auth/migrations/versions/001_initial_auth_tables.py b/services/auth/migrations/versions/001_initial_auth_tables.py deleted file mode 100644 index fc262465..00000000 --- a/services/auth/migrations/versions/001_initial_auth_tables.py +++ /dev/null @@ -1,29 +0,0 @@ -"""Initial auth service tables - -Revision ID: 001_initial_auth -Revises: -Create Date: 2024-01-01 12:00:00.000000 - -""" -from typing import Sequence, Union - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision: str = '001_initial_auth' -down_revision: Union[str, None] = None -branch_labels: Union[str, Sequence[str], None] = None -depends_on: Union[str, Sequence[str], None] = None - - -def upgrade() -> None: - # TODO: Add table creation statements for alert_processor service - # This is a placeholder migration - replace with actual table definitions - pass - - -def downgrade() -> None: - # TODO: Add table drop statements for alert_processor service - pass diff --git a/services/external/Dockerfile b/services/external/Dockerfile index e59a43e4..56e9f8d8 100644 --- a/services/external/Dockerfile +++ b/services/external/Dockerfile @@ -20,6 +20,10 @@ COPY shared/ /app/shared/ # Copy application code COPY services/external/app/ /app/app/ +# Copy migrations and alembic config +COPY services/external/migrations/ /app/migrations/ +COPY services/external/alembic.ini /app/alembic.ini + # Copy scripts directory COPY scripts/ /app/scripts/ diff --git a/services/external/migrations/versions/001_initial_external_tables.py b/services/external/migrations/versions/001_initial_external_tables.py deleted file mode 100644 index d45b9672..00000000 --- a/services/external/migrations/versions/001_initial_external_tables.py +++ /dev/null @@ -1,29 +0,0 @@ -"""Initial external service tables - -Revision ID: 001_initial_external -Revises: -Create Date: 2024-01-01 12:00:00.000000 - -""" -from typing import Sequence, Union - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision: str = '001_initial_external' -down_revision: Union[str, None] = None -branch_labels: Union[str, Sequence[str], None] = None -depends_on: Union[str, Sequence[str], None] = None - - -def upgrade() -> None: - # TODO: Add table creation statements for external service - # This is a placeholder migration - replace with actual table definitions - pass - - -def downgrade() -> None: - # TODO: Add table drop statements for external service - pass diff --git a/services/forecasting/Dockerfile b/services/forecasting/Dockerfile index 37bb2634..ed4d2bc5 100644 --- a/services/forecasting/Dockerfile +++ b/services/forecasting/Dockerfile @@ -26,6 +26,9 @@ COPY --from=shared /shared /app/shared # Copy application code COPY services/forecasting/ . +# Copy scripts directory +COPY scripts/ /app/scripts/ + # Add shared libraries to Python path ENV PYTHONPATH="/app:/app/shared:${PYTHONPATH:-}" diff --git a/services/forecasting/app/models/__init__.py b/services/forecasting/app/models/__init__.py index e69de29b..fd097991 100644 --- a/services/forecasting/app/models/__init__.py +++ b/services/forecasting/app/models/__init__.py @@ -0,0 +1,16 @@ +""" +Forecasting Service Models Package + +Import all models to ensure they are registered with SQLAlchemy Base. +""" + +# Import all models to register them with the Base metadata +from .forecasts import Forecast +from .predictions import ModelPerformanceMetric, PredictionCache + +# List all models for easier access +__all__ = [ + "Forecast", + "ModelPerformanceMetric", + "PredictionCache", +] \ No newline at end of file diff --git a/services/forecasting/migrations/versions/001_initial_tables.py b/services/forecasting/migrations/versions/001_initial_tables.py deleted file mode 100644 index a5433040..00000000 --- a/services/forecasting/migrations/versions/001_initial_tables.py +++ /dev/null @@ -1,28 +0,0 @@ -"""Initial forecasting service tables - -Revision ID: 001_initial_forecasting -Create Date: 2024-01-01 12:00:00.000000 - -""" -from typing import Sequence, Union - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision: str = '001_initial_forecasting' -down_revision: Union[str, None] = None -branch_labels: Union[str, Sequence[str], None] = None -depends_on: Union[str, Sequence[str], None] = None - - -def upgrade() -> None: - # TODO: Add table creation statements for forecasting service - # This is a placeholder migration - replace with actual table definitions - pass - - -def downgrade() -> None: - # TODO: Add table drop statements for forecasting service - pass diff --git a/services/inventory/Dockerfile b/services/inventory/Dockerfile index cc843296..979666d0 100644 --- a/services/inventory/Dockerfile +++ b/services/inventory/Dockerfile @@ -19,6 +19,10 @@ COPY shared/ /app/shared/ # Copy application code COPY services/inventory/app/ /app/app/ +# Copy migrations and alembic config +COPY services/inventory/migrations/ /app/migrations/ +COPY services/inventory/alembic.ini /app/alembic.ini + # Copy scripts directory COPY scripts/ /app/scripts/ diff --git a/services/inventory/migrations/versions/001_initial_inventory_tables.py b/services/inventory/migrations/versions/001_initial_inventory_tables.py deleted file mode 100644 index eb49f036..00000000 --- a/services/inventory/migrations/versions/001_initial_inventory_tables.py +++ /dev/null @@ -1,28 +0,0 @@ -"""Initial inventory service tables - -Revision ID: 001_initial_inventory -Create Date: 2024-01-01 12:00:00.000000 - -""" -from typing import Sequence, Union - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision: str = '001_initial_inventory' -down_revision: Union[str, None] = None -branch_labels: Union[str, Sequence[str], None] = None -depends_on: Union[str, Sequence[str], None] = None - - -def upgrade() -> None: - # TODO: Add table creation statements for inventory service - # This is a placeholder migration - replace with actual table definitions - pass - - -def downgrade() -> None: - # TODO: Add table drop statements for inventory service - pass diff --git a/services/notification/Dockerfile b/services/notification/Dockerfile index 6f4d0232..28ad5be1 100644 --- a/services/notification/Dockerfile +++ b/services/notification/Dockerfile @@ -26,6 +26,9 @@ COPY --from=shared /shared /app/shared # Copy application code COPY services/notification/ . +# Copy scripts directory +COPY scripts/ /app/scripts/ + # Add shared libraries to Python path ENV PYTHONPATH="/app:/app/shared:${PYTHONPATH:-}" diff --git a/services/notification/app/models/__init__.py b/services/notification/app/models/__init__.py index e69de29b..01c31099 100644 --- a/services/notification/app/models/__init__.py +++ b/services/notification/app/models/__init__.py @@ -0,0 +1,31 @@ +""" +Notification Service Models Package + +Import all models to ensure they are registered with SQLAlchemy Base. +""" + +# Import all models to register them with the Base metadata +from .notifications import ( + Notification, + NotificationType, + NotificationStatus, + NotificationPriority, + NotificationPreference, + NotificationLog, +) +from .templates import ( + EmailTemplate, + WhatsAppTemplate, +) + +# List all models for easier access +__all__ = [ + "Notification", + "NotificationType", + "NotificationStatus", + "NotificationPriority", + "NotificationPreference", + "NotificationLog", + "EmailTemplate", + "WhatsAppTemplate", +] \ No newline at end of file diff --git a/services/notification/migrations/versions/001_initial_notification_tables.py b/services/notification/migrations/versions/001_initial_notification_tables.py deleted file mode 100644 index 5875ae05..00000000 --- a/services/notification/migrations/versions/001_initial_notification_tables.py +++ /dev/null @@ -1,29 +0,0 @@ -"""Initial notification service tables - -Revision ID: 001_initial_notification -Revises: -Create Date: 2024-01-01 12:00:00.000000 - -""" -from typing import Sequence, Union - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision: str = '001_initial_notification' -down_revision: Union[str, None] = None -branch_labels: Union[str, Sequence[str], None] = None -depends_on: Union[str, Sequence[str], None] = None - - -def upgrade() -> None: - # TODO: Add table creation statements for notification service - # This is a placeholder migration - replace with actual table definitions - pass - - -def downgrade() -> None: - # TODO: Add table drop statements for notification service - pass diff --git a/services/orders/Dockerfile b/services/orders/Dockerfile index 791071e2..9fcf5a31 100644 --- a/services/orders/Dockerfile +++ b/services/orders/Dockerfile @@ -18,6 +18,13 @@ COPY shared/ ./shared/ # Copy application code COPY services/orders/app/ ./app/ +# Copy migrations and alembic config +COPY services/orders/migrations/ /app/migrations/ +COPY services/orders/alembic.ini /app/alembic.ini + +# Copy scripts directory +COPY scripts/ ./scripts/ + # Create logs directory RUN mkdir -p logs diff --git a/services/orders/app/main.py b/services/orders/app/main.py index ba5dee99..3f2f637f 100644 --- a/services/orders/app/main.py +++ b/services/orders/app/main.py @@ -110,7 +110,7 @@ async def test_procurement_scheduler(): else: return {"error": "Scheduler service not available"} except Exception as e: - logger.error("Error testing procurement scheduler", error=str(e)) + service.logger.error("Error testing procurement scheduler", error=str(e)) return {"error": f"Failed to trigger scheduler test: {str(e)}"} @@ -118,17 +118,17 @@ async def test_procurement_scheduler(): async def logging_middleware(request: Request, call_next): """Add request logging middleware""" import time - + start_time = time.time() response = await call_next(request) process_time = time.time() - start_time - - logger.info("HTTP request processed", + + service.logger.info("HTTP request processed", method=request.method, url=str(request.url), status_code=response.status_code, process_time=round(process_time, 4)) - + return response diff --git a/services/orders/app/models/__init__.py b/services/orders/app/models/__init__.py new file mode 100644 index 00000000..7e143c85 --- /dev/null +++ b/services/orders/app/models/__init__.py @@ -0,0 +1,21 @@ +""" +Orders Service Models Package + +Import all models to ensure they are registered with SQLAlchemy Base. +""" + +# Import all models to register them with the Base metadata +from .customer import Customer, CustomerContact +from .order import CustomerOrder, OrderItem, OrderStatusHistory +from .procurement import ProcurementPlan, ProcurementRequirement + +# List all models for easier access +__all__ = [ + "Customer", + "CustomerContact", + "CustomerOrder", + "OrderItem", + "OrderStatusHistory", + "ProcurementPlan", + "ProcurementRequirement" +] diff --git a/services/orders/migrations/versions/001_initial_orders_tables.py b/services/orders/migrations/versions/001_initial_orders_tables.py deleted file mode 100644 index ff722189..00000000 --- a/services/orders/migrations/versions/001_initial_orders_tables.py +++ /dev/null @@ -1,29 +0,0 @@ -"""Initial orders service tables - -Revision ID: 001_initial_orders -Revises: -Create Date: 2024-01-01 12:00:00.000000 - -""" -from typing import Sequence, Union - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision: str = '001_initial_orders' -down_revision: Union[str, None] = None -branch_labels: Union[str, Sequence[str], None] = None -depends_on: Union[str, Sequence[str], None] = None - - -def upgrade() -> None: - # TODO: Add table creation statements for orders service - # This is a placeholder migration - replace with actual table definitions - pass - - -def downgrade() -> None: - # TODO: Add table drop statements for orders service - pass diff --git a/services/pos/Dockerfile b/services/pos/Dockerfile index 9cb4322e..aab5a31b 100644 --- a/services/pos/Dockerfile +++ b/services/pos/Dockerfile @@ -15,6 +15,13 @@ RUN pip install --no-cache-dir -r requirements.txt COPY services/pos/app ./app COPY shared ./shared +# Copy migrations and alembic config +COPY services/pos/migrations/ /app/migrations/ +COPY services/pos/alembic.ini /app/alembic.ini + +# Copy scripts directory +COPY scripts ./scripts + # Create necessary directories RUN mkdir -p logs diff --git a/services/pos/migrations/versions/001_initial_pos_tables.py b/services/pos/migrations/versions/001_initial_pos_tables.py deleted file mode 100644 index 8ac50d71..00000000 --- a/services/pos/migrations/versions/001_initial_pos_tables.py +++ /dev/null @@ -1,28 +0,0 @@ -"""Initial POS service tables - -Revision ID: 001_initial_pos -Create Date: 2024-01-01 12:00:00.000000 - -""" -from typing import Sequence, Union - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision: str = '001_initial_pos' -down_revision: Union[str, None] = None -branch_labels: Union[str, Sequence[str], None] = None -depends_on: Union[str, Sequence[str], None] = None - - -def upgrade() -> None: - # TODO: Add table creation statements for POS service - # This is a placeholder migration - replace with actual table definitions - pass - - -def downgrade() -> None: - # TODO: Add table drop statements for POS service - pass diff --git a/services/production/Dockerfile b/services/production/Dockerfile index b583c423..8d2014dc 100644 --- a/services/production/Dockerfile +++ b/services/production/Dockerfile @@ -18,6 +18,13 @@ COPY shared/ ./shared/ # Copy application code COPY services/production/app/ ./app/ +# Copy migrations and alembic config +COPY services/production/migrations/ /app/migrations/ +COPY services/production/alembic.ini /app/alembic.ini + +# Copy scripts directory +COPY scripts/ ./scripts/ + # Create logs directory RUN mkdir -p logs diff --git a/services/production/app/models/__init__.py b/services/production/app/models/__init__.py index 3ba5184a..65e25323 100644 --- a/services/production/app/models/__init__.py +++ b/services/production/app/models/__init__.py @@ -9,12 +9,26 @@ from .production import ( ProductionBatch, ProductionSchedule, ProductionCapacity, - QualityCheck + QualityCheckTemplate, + QualityCheck, + Equipment, + ProductionStatus, + ProductionPriority, + EquipmentStatus, + ProcessStage, + EquipmentType, ) __all__ = [ "ProductionBatch", - "ProductionSchedule", + "ProductionSchedule", "ProductionCapacity", - "QualityCheck" + "QualityCheckTemplate", + "QualityCheck", + "Equipment", + "ProductionStatus", + "ProductionPriority", + "EquipmentStatus", + "ProcessStage", + "EquipmentType", ] \ No newline at end of file diff --git a/services/production/migrations/versions/001_initial_production_tables.py b/services/production/migrations/versions/001_initial_production_tables.py deleted file mode 100644 index 8568c667..00000000 --- a/services/production/migrations/versions/001_initial_production_tables.py +++ /dev/null @@ -1,29 +0,0 @@ -"""Initial production service tables - -Revision ID: 001_initial_production -Revises: -Create Date: 2024-01-01 12:00:00.000000 - -""" -from typing import Sequence, Union - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision: str = '001_initial_production' -down_revision: Union[str, None] = None -branch_labels: Union[str, Sequence[str], None] = None -depends_on: Union[str, Sequence[str], None] = None - - -def upgrade() -> None: - # TODO: Add table creation statements for production service - # This is a placeholder migration - replace with actual table definitions - pass - - -def downgrade() -> None: - # TODO: Add table drop statements for production service - pass diff --git a/services/recipes/Dockerfile b/services/recipes/Dockerfile index 3ef642a4..0e7e7708 100644 --- a/services/recipes/Dockerfile +++ b/services/recipes/Dockerfile @@ -18,6 +18,13 @@ COPY shared/ ./shared/ # Copy application code COPY services/recipes/app/ ./app/ +# Copy migrations and alembic config +COPY services/recipes/migrations/ /app/migrations/ +COPY services/recipes/alembic.ini /app/alembic.ini + +# Copy scripts directory +COPY scripts/ ./scripts/ + # Create logs directory RUN mkdir -p logs diff --git a/services/recipes/migrations/versions/001_initial_recipe_tables.py b/services/recipes/migrations/versions/001_initial_recipe_tables.py deleted file mode 100644 index e71e9668..00000000 --- a/services/recipes/migrations/versions/001_initial_recipe_tables.py +++ /dev/null @@ -1,29 +0,0 @@ -"""Initial ecipes service tables - -Revision ID: 001_initial_recipes -Revises: -Create Date: 2024-01-01 12:00:00.000000 - -""" -from typing import Sequence, Union - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision: str = '001_initial_recipes' -down_revision: Union[str, None] = None -branch_labels: Union[str, Sequence[str], None] = None -depends_on: Union[str, Sequence[str], None] = None - - -def upgrade() -> None: - # TODO: Add table creation statements for ecipes service - # This is a placeholder migration - replace with actual table definitions - pass - - -def downgrade() -> None: - # TODO: Add table drop statements for ecipes service - pass diff --git a/services/sales/Dockerfile b/services/sales/Dockerfile index 36281e46..3f0293ca 100644 --- a/services/sales/Dockerfile +++ b/services/sales/Dockerfile @@ -19,6 +19,13 @@ COPY shared/ /app/shared/ # Copy application code COPY services/sales/app/ /app/app/ +# Copy migrations and alembic config +COPY services/sales/migrations/ /app/migrations/ +COPY services/sales/alembic.ini /app/alembic.ini + +# Copy scripts directory +COPY scripts/ /app/scripts/ + # Set Python path to include shared modules ENV PYTHONPATH=/app diff --git a/services/sales/migrations/versions/001_initial_sales_tables.py b/services/sales/migrations/versions/001_initial_sales_tables.py deleted file mode 100644 index 2574a1c9..00000000 --- a/services/sales/migrations/versions/001_initial_sales_tables.py +++ /dev/null @@ -1,29 +0,0 @@ -"""Initial sales service tables - -Revision ID: 001_initial_sales -Revises: -Create Date: 2024-01-01 12:00:00.000000 - -""" -from typing import Sequence, Union - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision: str = '001_initial_sales' -down_revision: Union[str, None] = None -branch_labels: Union[str, Sequence[str], None] = None -depends_on: Union[str, Sequence[str], None] = None - - -def upgrade() -> None: - # TODO: Add table creation statements for sales service - # This is a placeholder migration - replace with actual table definitions - pass - - -def downgrade() -> None: - # TODO: Add table drop statements for sales service - pass diff --git a/services/suppliers/Dockerfile b/services/suppliers/Dockerfile index b4fbb789..6ae2830c 100644 --- a/services/suppliers/Dockerfile +++ b/services/suppliers/Dockerfile @@ -19,6 +19,13 @@ COPY shared/ /app/shared/ # Copy application code COPY services/suppliers/app/ /app/app/ +# Copy migrations and alembic config +COPY services/suppliers/migrations/ /app/migrations/ +COPY services/suppliers/alembic.ini /app/alembic.ini + +# Copy scripts directory +COPY scripts/ /app/scripts/ + # Set Python path to include shared modules ENV PYTHONPATH=/app diff --git a/services/suppliers/migrations/versions/001_initial_suppliers_tables.py b/services/suppliers/migrations/versions/001_initial_suppliers_tables.py deleted file mode 100644 index 5e606d5f..00000000 --- a/services/suppliers/migrations/versions/001_initial_suppliers_tables.py +++ /dev/null @@ -1,29 +0,0 @@ -"""Initial supplioers service tables - -Revision ID: 001_initial_suppliers -Revises: -Create Date: 2024-01-01 12:00:00.000000 - -""" -from typing import Sequence, Union - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision: str = '001_initial_suppliers' -down_revision: Union[str, None] = None -branch_labels: Union[str, Sequence[str], None] = None -depends_on: Union[str, Sequence[str], None] = None - - -def upgrade() -> None: - # TODO: Add table creation statements for suppliers service - # This is a placeholder migration - replace with actual table definitions - pass - - -def downgrade() -> None: - # TODO: Add table drop statements for suppliers service - pass diff --git a/services/tenant/Dockerfile b/services/tenant/Dockerfile index 25e0b7e0..10d80978 100644 --- a/services/tenant/Dockerfile +++ b/services/tenant/Dockerfile @@ -26,6 +26,9 @@ COPY --from=shared /shared /app/shared # Copy application code COPY services/tenant/ . +# Copy scripts directory +COPY scripts/ /app/scripts/ + # Add shared libraries to Python path ENV PYTHONPATH="/app:/app/shared:${PYTHONPATH:-}" diff --git a/services/tenant/app/models/__init__.py b/services/tenant/app/models/__init__.py index e69de29b..421ae586 100644 --- a/services/tenant/app/models/__init__.py +++ b/services/tenant/app/models/__init__.py @@ -0,0 +1,15 @@ +""" +Tenant Service Models Package + +Import all models to ensure they are registered with SQLAlchemy Base. +""" + +# Import all models to register them with the Base metadata +from .tenants import Tenant, TenantMember, Subscription + +# List all models for easier access +__all__ = [ + "Tenant", + "TenantMember", + "Subscription", +] diff --git a/services/tenant/migrations/versions/001_initial_tenant_tables.py b/services/tenant/migrations/versions/001_initial_tenant_tables.py deleted file mode 100644 index 783e7b26..00000000 --- a/services/tenant/migrations/versions/001_initial_tenant_tables.py +++ /dev/null @@ -1,29 +0,0 @@ -"""Initial tenant service tables - -Revision ID: 001_initial_tenant -Revises: -Create Date: 2024-01-01 12:00:00.000000 - -""" -from typing import Sequence, Union - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision: str = '001_initial_tenant' -down_revision: Union[str, None] = None -branch_labels: Union[str, Sequence[str], None] = None -depends_on: Union[str, Sequence[str], None] = None - - -def upgrade() -> None: - # TODO: Add table creation statements for tenant service - # This is a placeholder migration - replace with actual table definitions - pass - - -def downgrade() -> None: - # TODO: Add table drop statements for teannt service - pass diff --git a/services/training/Dockerfile b/services/training/Dockerfile index b7ecc50a..12081b2c 100644 --- a/services/training/Dockerfile +++ b/services/training/Dockerfile @@ -26,6 +26,9 @@ COPY --from=shared /shared /app/shared # Copy application code COPY services/training/ . +# Copy scripts directory +COPY scripts/ /app/scripts/ + # Add shared libraries to Python path ENV PYTHONPATH="/app:/app/shared:${PYTHONPATH:-}" diff --git a/services/training/app/models/__init__.py b/services/training/app/models/__init__.py index e69de29b..8f2c9dfa 100644 --- a/services/training/app/models/__init__.py +++ b/services/training/app/models/__init__.py @@ -0,0 +1,23 @@ +""" +Training Service Models Package + +Import all models to ensure they are registered with SQLAlchemy Base. +""" + +# Import all models to register them with the Base metadata +from .training import ( + TrainedModel, + ModelTrainingLog, + ModelPerformanceMetric, + TrainingJobQueue, + ModelArtifact, +) + +# List all models for easier access +__all__ = [ + "TrainedModel", + "ModelTrainingLog", + "ModelPerformanceMetric", + "TrainingJobQueue", + "ModelArtifact", +] diff --git a/services/training/migrations/versions/001_initial_training_tables.py b/services/training/migrations/versions/001_initial_training_tables.py deleted file mode 100644 index f76295f6..00000000 --- a/services/training/migrations/versions/001_initial_training_tables.py +++ /dev/null @@ -1,29 +0,0 @@ -"""Initial training service tables - -Revision ID: 001_initial_training -Revises: -Create Date: 2024-01-01 12:00:00.000000 - -""" -from typing import Sequence, Union - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision: str = '001_initial_training' -down_revision: Union[str, None] = None -branch_labels: Union[str, Sequence[str], None] = None -depends_on: Union[str, Sequence[str], None] = None - - -def upgrade() -> None: - # TODO: Add table creation statements for training service - # This is a placeholder migration - replace with actual table definitions - pass - - -def downgrade() -> None: - # TODO: Add table drop statements for training service - pass