diff --git a/.DS_Store b/.DS_Store index 2bfdc62..74bee2e 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/.env b/.env new file mode 100644 index 0000000..5db9aef --- /dev/null +++ b/.env @@ -0,0 +1,4 @@ +DB_HOST=localhost +DB_USER=luke +DB_PASS=Skywalker! +DB_NAME=eveai diff --git a/common/__pycache__/__init__.cpython-312.pyc b/common/__pycache__/__init__.cpython-312.pyc index 4942759..0852227 100644 Binary files a/common/__pycache__/__init__.cpython-312.pyc and b/common/__pycache__/__init__.cpython-312.pyc differ diff --git a/common/__pycache__/extensions.cpython-312.pyc b/common/__pycache__/extensions.cpython-312.pyc index 18d9688..29e10e5 100644 Binary files a/common/__pycache__/extensions.cpython-312.pyc and b/common/__pycache__/extensions.cpython-312.pyc differ diff --git a/common/models/__pycache__/__init__.cpython-312.pyc b/common/models/__pycache__/__init__.cpython-312.pyc index c37d6cd..11892cf 100644 Binary files a/common/models/__pycache__/__init__.cpython-312.pyc and b/common/models/__pycache__/__init__.cpython-312.pyc differ diff --git a/common/models/__pycache__/document.cpython-312.pyc b/common/models/__pycache__/document.cpython-312.pyc index 6b90d33..471fdd2 100644 Binary files a/common/models/__pycache__/document.cpython-312.pyc and b/common/models/__pycache__/document.cpython-312.pyc differ diff --git a/common/models/__pycache__/interaction.cpython-312.pyc b/common/models/__pycache__/interaction.cpython-312.pyc index 61512ff..70d8fa6 100644 Binary files a/common/models/__pycache__/interaction.cpython-312.pyc and b/common/models/__pycache__/interaction.cpython-312.pyc differ diff --git a/common/models/__pycache__/user.cpython-312.pyc b/common/models/__pycache__/user.cpython-312.pyc index caea351..596b235 100644 Binary files a/common/models/__pycache__/user.cpython-312.pyc and b/common/models/__pycache__/user.cpython-312.pyc differ diff --git a/common/models/document.py b/common/models/document.py index 4b06a49..aeed9a3 100644 --- a/common/models/document.py +++ b/common/models/document.py @@ -97,3 +97,16 @@ class EmbeddingSmallOpenAI(Embedding): __mapper_args__ = { 'polymorphic_identity': 'embedding_small_openai', } + + +class EmbeddingLargeOpenAI(Embedding): + __tablename__ = 'embedding_large_openai' + id = db.Column(db.Integer, db.ForeignKey('embeddings.id'), primary_key=True) + + # 3072 is the OpenAI Large Embedding dimension. + # If another embedding model is chosen, this dimension may need to be changed. + embedding = db.Column(Vector(3072), nullable=False) + + __mapper_args__ = { + 'polymorphic_identity': 'embedding_large_openai', + } diff --git a/common/utils/__pycache__/__init__.cpython-312.pyc b/common/utils/__pycache__/__init__.cpython-312.pyc index d8a689e..db92efb 100644 Binary files a/common/utils/__pycache__/__init__.cpython-312.pyc and b/common/utils/__pycache__/__init__.cpython-312.pyc differ diff --git a/common/utils/__pycache__/celery_utils.cpython-312.pyc b/common/utils/__pycache__/celery_utils.cpython-312.pyc index 0f4c2f6..0ec5442 100644 Binary files a/common/utils/__pycache__/celery_utils.cpython-312.pyc and b/common/utils/__pycache__/celery_utils.cpython-312.pyc differ diff --git a/common/utils/__pycache__/database.cpython-312.pyc b/common/utils/__pycache__/database.cpython-312.pyc index d1f0d8f..93870c4 100644 Binary files a/common/utils/__pycache__/database.cpython-312.pyc and b/common/utils/__pycache__/database.cpython-312.pyc differ diff --git a/common/utils/__pycache__/key_encryption.cpython-312.pyc b/common/utils/__pycache__/key_encryption.cpython-312.pyc index 38a363d..a81d7e7 100644 Binary files a/common/utils/__pycache__/key_encryption.cpython-312.pyc and b/common/utils/__pycache__/key_encryption.cpython-312.pyc differ diff --git a/common/utils/__pycache__/middleware.cpython-312.pyc b/common/utils/__pycache__/middleware.cpython-312.pyc index 59cf06f..815e2c1 100644 Binary files a/common/utils/__pycache__/middleware.cpython-312.pyc and b/common/utils/__pycache__/middleware.cpython-312.pyc differ diff --git a/common/utils/__pycache__/nginx_utils.cpython-312.pyc b/common/utils/__pycache__/nginx_utils.cpython-312.pyc index 508e38d..b5d239f 100644 Binary files a/common/utils/__pycache__/nginx_utils.cpython-312.pyc and b/common/utils/__pycache__/nginx_utils.cpython-312.pyc differ diff --git a/common/utils/__pycache__/security.cpython-312.pyc b/common/utils/__pycache__/security.cpython-312.pyc index f5ac1bf..a95c177 100644 Binary files a/common/utils/__pycache__/security.cpython-312.pyc and b/common/utils/__pycache__/security.cpython-312.pyc differ diff --git a/common/utils/__pycache__/security_utils.cpython-312.pyc b/common/utils/__pycache__/security_utils.cpython-312.pyc index 0a5a082..842a2e9 100644 Binary files a/common/utils/__pycache__/security_utils.cpython-312.pyc and b/common/utils/__pycache__/security_utils.cpython-312.pyc differ diff --git a/common/utils/__pycache__/template_filters.cpython-312.pyc b/common/utils/__pycache__/template_filters.cpython-312.pyc index e352b56..6aeaba8 100644 Binary files a/common/utils/__pycache__/template_filters.cpython-312.pyc and b/common/utils/__pycache__/template_filters.cpython-312.pyc differ diff --git a/common/utils/__pycache__/view_assistants.cpython-312.pyc b/common/utils/__pycache__/view_assistants.cpython-312.pyc index 3959100..6b1ae74 100644 Binary files a/common/utils/__pycache__/view_assistants.cpython-312.pyc and b/common/utils/__pycache__/view_assistants.cpython-312.pyc differ diff --git a/config/__pycache__/__init__.cpython-312.pyc b/config/__pycache__/__init__.cpython-312.pyc index 1cb6791..381a0b7 100644 Binary files a/config/__pycache__/__init__.cpython-312.pyc and b/config/__pycache__/__init__.cpython-312.pyc differ diff --git a/config/__pycache__/config.cpython-312.pyc b/config/__pycache__/config.cpython-312.pyc index d3c37bd..c697c03 100644 Binary files a/config/__pycache__/config.cpython-312.pyc and b/config/__pycache__/config.cpython-312.pyc differ diff --git a/config/__pycache__/logging_config.cpython-312.pyc b/config/__pycache__/logging_config.cpython-312.pyc index 87de852..8e971ca 100644 Binary files a/config/__pycache__/logging_config.cpython-312.pyc and b/config/__pycache__/logging_config.cpython-312.pyc differ diff --git a/config/config.py b/config/config.py index 90da352..39c0801 100644 --- a/config/config.py +++ b/config/config.py @@ -71,6 +71,8 @@ class Config(object): # Chunk Definition, Embedding dependent OAI_TE3S_MIN_CHUNK_SIZE = 2000 OAI_TE3S_MAX_CHUNK_SIZE = 3000 + OAI_TE3L_MIN_CHUNK_SIZE = 3000 + OAI_TE3L_MAX_CHUNK_SIZE = 4000 # LLM TEMPLATES GPT4_SUMMARY_TEMPLATE = """Write a concise summary of the text in {language}. The text is delimited between triple backquotes. @@ -182,8 +184,13 @@ class DevConfig(Config): DEBUG = True FLASK_DEBUG = True PYCHARM_DEBUG = False - SQLALCHEMY_DATABASE_URI = 'postgresql+pg8000://luke:Skywalker!@db:5432/eveai' - SQLALCHEMY_BINDS = {'public': 'postgresql+pg8000://luke:Skywalker!@db:5432/eveai'} + DB_HOST = environ.get('DB_HOST', 'localhost') + DB_USER = environ.get('DB_USER', 'luke') + DB_PASS = environ.get('DB_PASS', 'Skywalker!') + DB_NAME = environ.get('DB_NAME', 'eveai') + + SQLALCHEMY_DATABASE_URI = f'postgresql+pg8000://{DB_USER}:{DB_PASS}@{DB_HOST}:5432/{DB_NAME}' + SQLALCHEMY_BINDS = {'public': SQLALCHEMY_DATABASE_URI} EXPLAIN_TEMPLATE_LOADING = False # Define the nginx prefix used for the specific apps diff --git a/docker/.DS_Store b/docker/.DS_Store index ed9d9e0..071ab93 100644 Binary files a/docker/.DS_Store and b/docker/.DS_Store differ diff --git a/docker/compose.yaml b/docker/compose.yaml index 30822df..51a5f8f 100644 --- a/docker/compose.yaml +++ b/docker/compose.yaml @@ -32,6 +32,10 @@ services: environment: - FLASK_ENV=development - FLASK_DEBUG=1 + - DB_HOST=db + - DB_USER=luke + - DB_PASS=Skywalker! + - DB_NAME=eveai volumes: - ../eveai_app:/app/eveai_app - ../common:/app/common diff --git a/docker/db/.DS_Store b/docker/db/.DS_Store index 6d4aeb6..cef92d0 100644 Binary files a/docker/db/.DS_Store and b/docker/db/.DS_Store differ diff --git a/eveai_app/.DS_Store b/eveai_app/.DS_Store index c55fc8f..a049e9c 100644 Binary files a/eveai_app/.DS_Store and b/eveai_app/.DS_Store differ diff --git a/eveai_app/__pycache__/__init__.cpython-312.pyc b/eveai_app/__pycache__/__init__.cpython-312.pyc index 3e49418..9e1c516 100644 Binary files a/eveai_app/__pycache__/__init__.cpython-312.pyc and b/eveai_app/__pycache__/__init__.cpython-312.pyc differ diff --git a/eveai_app/__pycache__/errors.cpython-312.pyc b/eveai_app/__pycache__/errors.cpython-312.pyc index 024fd2a..ea652c7 100644 Binary files a/eveai_app/__pycache__/errors.cpython-312.pyc and b/eveai_app/__pycache__/errors.cpython-312.pyc differ diff --git a/eveai_app/views/__pycache__/__init__.cpython-312.pyc b/eveai_app/views/__pycache__/__init__.cpython-312.pyc index 85025a5..95ac753 100644 Binary files a/eveai_app/views/__pycache__/__init__.cpython-312.pyc and b/eveai_app/views/__pycache__/__init__.cpython-312.pyc differ diff --git a/eveai_app/views/__pycache__/basic_forms.cpython-312.pyc b/eveai_app/views/__pycache__/basic_forms.cpython-312.pyc index 0dec307..c57710c 100644 Binary files a/eveai_app/views/__pycache__/basic_forms.cpython-312.pyc and b/eveai_app/views/__pycache__/basic_forms.cpython-312.pyc differ diff --git a/eveai_app/views/__pycache__/basic_views.cpython-312.pyc b/eveai_app/views/__pycache__/basic_views.cpython-312.pyc index b7236b3..fbf1ed7 100644 Binary files a/eveai_app/views/__pycache__/basic_views.cpython-312.pyc and b/eveai_app/views/__pycache__/basic_views.cpython-312.pyc differ diff --git a/eveai_app/views/__pycache__/document_forms.cpython-312.pyc b/eveai_app/views/__pycache__/document_forms.cpython-312.pyc index 6c0ef7b..e747df5 100644 Binary files a/eveai_app/views/__pycache__/document_forms.cpython-312.pyc and b/eveai_app/views/__pycache__/document_forms.cpython-312.pyc differ diff --git a/eveai_app/views/__pycache__/document_views.cpython-312.pyc b/eveai_app/views/__pycache__/document_views.cpython-312.pyc index 4e37d24..a3496d6 100644 Binary files a/eveai_app/views/__pycache__/document_views.cpython-312.pyc and b/eveai_app/views/__pycache__/document_views.cpython-312.pyc differ diff --git a/eveai_app/views/__pycache__/interaction_views.cpython-312.pyc b/eveai_app/views/__pycache__/interaction_views.cpython-312.pyc index f6690a9..fe83f8c 100644 Binary files a/eveai_app/views/__pycache__/interaction_views.cpython-312.pyc and b/eveai_app/views/__pycache__/interaction_views.cpython-312.pyc differ diff --git a/eveai_app/views/__pycache__/security_forms.cpython-312.pyc b/eveai_app/views/__pycache__/security_forms.cpython-312.pyc index adad905..f1ea398 100644 Binary files a/eveai_app/views/__pycache__/security_forms.cpython-312.pyc and b/eveai_app/views/__pycache__/security_forms.cpython-312.pyc differ diff --git a/eveai_app/views/__pycache__/security_views.cpython-312.pyc b/eveai_app/views/__pycache__/security_views.cpython-312.pyc index 25be653..e80bd3b 100644 Binary files a/eveai_app/views/__pycache__/security_views.cpython-312.pyc and b/eveai_app/views/__pycache__/security_views.cpython-312.pyc differ diff --git a/eveai_app/views/__pycache__/user_forms.cpython-312.pyc b/eveai_app/views/__pycache__/user_forms.cpython-312.pyc index 6e4fd15..4ad27c1 100644 Binary files a/eveai_app/views/__pycache__/user_forms.cpython-312.pyc and b/eveai_app/views/__pycache__/user_forms.cpython-312.pyc differ diff --git a/eveai_app/views/__pycache__/user_views.cpython-312.pyc b/eveai_app/views/__pycache__/user_views.cpython-312.pyc index 79b6e48..3859279 100644 Binary files a/eveai_app/views/__pycache__/user_views.cpython-312.pyc and b/eveai_app/views/__pycache__/user_views.cpython-312.pyc differ diff --git a/logs/embed_tuning.log b/logs/embed_tuning.log new file mode 100644 index 0000000..e69de29 diff --git a/logs/eveai_app.log b/logs/eveai_app.log new file mode 100644 index 0000000..b789027 --- /dev/null +++ b/logs/eveai_app.log @@ -0,0 +1,66 @@ +2024-07-04 09:28:59,334 [INFO] eveai_app: eveai_app starting up +2024-07-04 09:28:59,353 [INFO] eveai_app: Project ID: eveai-420711 +2024-07-04 09:28:59,353 [INFO] eveai_app: Location: europe-west1 +2024-07-04 09:28:59,353 [INFO] eveai_app: Key Ring: eveai-chat +2024-07-04 09:28:59,353 [INFO] eveai_app: Crypto Key: envelope-encryption-key +2024-07-04 09:28:59,353 [INFO] eveai_app: Key Name: projects/eveai-420711/locations/europe-west1/keyRings/eveai-chat/cryptoKeys/envelope-encryption-key +2024-07-04 09:28:59,354 [INFO] eveai_app: Service Account Key Path: None +2024-07-04 09:28:59,362 [DEBUG] eveai_app: CELERY_BROKER_URL: redis://redis:6379/0 +2024-07-04 09:28:59,362 [DEBUG] eveai_app: CELERY_RESULT_BACKEND: redis://redis:6379/0 +2024-07-04 09:28:59,399 [INFO] eveai_app: EveAI App Server Started Successfully +2024-07-04 09:28:59,399 [INFO] eveai_app: ------------------------------------------------------------------------------------------------- +2024-07-04 09:30:12,852 [INFO] eveai_app: eveai_app starting up +2024-07-04 09:30:12,870 [INFO] eveai_app: Project ID: eveai-420711 +2024-07-04 09:30:12,870 [INFO] eveai_app: Location: europe-west1 +2024-07-04 09:30:12,870 [INFO] eveai_app: Key Ring: eveai-chat +2024-07-04 09:30:12,870 [INFO] eveai_app: Crypto Key: envelope-encryption-key +2024-07-04 09:30:12,870 [INFO] eveai_app: Key Name: projects/eveai-420711/locations/europe-west1/keyRings/eveai-chat/cryptoKeys/envelope-encryption-key +2024-07-04 09:30:12,870 [INFO] eveai_app: Service Account Key Path: None +2024-07-04 09:30:12,874 [DEBUG] eveai_app: CELERY_BROKER_URL: redis://redis:6379/0 +2024-07-04 09:30:12,875 [DEBUG] eveai_app: CELERY_RESULT_BACKEND: redis://redis:6379/0 +2024-07-04 09:30:12,893 [INFO] eveai_app: EveAI App Server Started Successfully +2024-07-04 09:30:12,893 [INFO] eveai_app: ------------------------------------------------------------------------------------------------- +2024-07-04 09:30:23,727 [INFO] eveai_app: eveai_app starting up +2024-07-04 09:30:23,739 [INFO] eveai_app: Project ID: eveai-420711 +2024-07-04 09:30:23,740 [INFO] eveai_app: Location: europe-west1 +2024-07-04 09:30:23,740 [INFO] eveai_app: Key Ring: eveai-chat +2024-07-04 09:30:23,740 [INFO] eveai_app: Crypto Key: envelope-encryption-key +2024-07-04 09:30:23,740 [INFO] eveai_app: Key Name: projects/eveai-420711/locations/europe-west1/keyRings/eveai-chat/cryptoKeys/envelope-encryption-key +2024-07-04 09:30:23,740 [INFO] eveai_app: Service Account Key Path: None +2024-07-04 09:30:23,744 [DEBUG] eveai_app: CELERY_BROKER_URL: redis://redis:6379/0 +2024-07-04 09:30:23,744 [DEBUG] eveai_app: CELERY_RESULT_BACKEND: redis://redis:6379/0 +2024-07-04 09:30:23,762 [INFO] eveai_app: EveAI App Server Started Successfully +2024-07-04 09:30:23,762 [INFO] eveai_app: ------------------------------------------------------------------------------------------------- +2024-07-04 15:47:58,346 [INFO] eveai_app: eveai_app starting up +2024-07-04 15:47:58,365 [INFO] eveai_app: Project ID: eveai-420711 +2024-07-04 15:47:58,365 [INFO] eveai_app: Location: europe-west1 +2024-07-04 15:47:58,365 [INFO] eveai_app: Key Ring: eveai-chat +2024-07-04 15:47:58,365 [INFO] eveai_app: Crypto Key: envelope-encryption-key +2024-07-04 15:47:58,365 [INFO] eveai_app: Key Name: projects/eveai-420711/locations/europe-west1/keyRings/eveai-chat/cryptoKeys/envelope-encryption-key +2024-07-04 15:47:58,365 [INFO] eveai_app: Service Account Key Path: None +2024-07-04 15:47:58,383 [DEBUG] eveai_app: CELERY_BROKER_URL: redis://redis:6379/0 +2024-07-04 15:47:58,383 [DEBUG] eveai_app: CELERY_RESULT_BACKEND: redis://redis:6379/0 +2024-07-04 15:47:58,406 [INFO] eveai_app: EveAI App Server Started Successfully +2024-07-04 15:47:58,406 [INFO] eveai_app: ------------------------------------------------------------------------------------------------- +2024-07-04 15:48:39,272 [INFO] eveai_app: eveai_app starting up +2024-07-04 15:48:39,284 [INFO] eveai_app: Project ID: eveai-420711 +2024-07-04 15:48:39,284 [INFO] eveai_app: Location: europe-west1 +2024-07-04 15:48:39,284 [INFO] eveai_app: Key Ring: eveai-chat +2024-07-04 15:48:39,285 [INFO] eveai_app: Crypto Key: envelope-encryption-key +2024-07-04 15:48:39,285 [INFO] eveai_app: Key Name: projects/eveai-420711/locations/europe-west1/keyRings/eveai-chat/cryptoKeys/envelope-encryption-key +2024-07-04 15:48:39,285 [INFO] eveai_app: Service Account Key Path: None +2024-07-04 15:48:39,289 [DEBUG] eveai_app: CELERY_BROKER_URL: redis://redis:6379/0 +2024-07-04 15:48:39,289 [DEBUG] eveai_app: CELERY_RESULT_BACKEND: redis://redis:6379/0 +2024-07-04 15:48:39,307 [INFO] eveai_app: EveAI App Server Started Successfully +2024-07-04 15:48:39,308 [INFO] eveai_app: ------------------------------------------------------------------------------------------------- +2024-07-04 15:49:43,236 [INFO] eveai_app: eveai_app starting up +2024-07-04 15:49:43,248 [INFO] eveai_app: Project ID: eveai-420711 +2024-07-04 15:49:43,248 [INFO] eveai_app: Location: europe-west1 +2024-07-04 15:49:43,248 [INFO] eveai_app: Key Ring: eveai-chat +2024-07-04 15:49:43,248 [INFO] eveai_app: Crypto Key: envelope-encryption-key +2024-07-04 15:49:43,249 [INFO] eveai_app: Key Name: projects/eveai-420711/locations/europe-west1/keyRings/eveai-chat/cryptoKeys/envelope-encryption-key +2024-07-04 15:49:43,249 [INFO] eveai_app: Service Account Key Path: None +2024-07-04 15:49:43,253 [DEBUG] eveai_app: CELERY_BROKER_URL: redis://redis:6379/0 +2024-07-04 15:49:43,253 [DEBUG] eveai_app: CELERY_RESULT_BACKEND: redis://redis:6379/0 +2024-07-04 15:49:43,271 [INFO] eveai_app: EveAI App Server Started Successfully +2024-07-04 15:49:43,271 [INFO] eveai_app: ------------------------------------------------------------------------------------------------- diff --git a/logs/eveai_chat.log b/logs/eveai_chat.log new file mode 100644 index 0000000..e69de29 diff --git a/logs/eveai_chat_workers.log b/logs/eveai_chat_workers.log new file mode 100644 index 0000000..e69de29 diff --git a/logs/eveai_workers.log b/logs/eveai_workers.log new file mode 100644 index 0000000..e69de29 diff --git a/logs/mailman.log b/logs/mailman.log new file mode 100644 index 0000000..e69de29 diff --git a/logs/rag_tuning.log b/logs/rag_tuning.log new file mode 100644 index 0000000..e69de29 diff --git a/logs/security.log b/logs/security.log new file mode 100644 index 0000000..e69de29 diff --git a/logs/sqlalchemy.log b/logs/sqlalchemy.log new file mode 100644 index 0000000..e69de29 diff --git a/migrations/.DS_Store b/migrations/.DS_Store index 9746ac9..475a0f8 100644 Binary files a/migrations/.DS_Store and b/migrations/.DS_Store differ diff --git a/migrations/public/.DS_Store b/migrations/public/.DS_Store index 8e00ba4..d0de5df 100644 Binary files a/migrations/public/.DS_Store and b/migrations/public/.DS_Store differ diff --git a/migrations/public/versions/167d821471ed_2024_07_04t09_42_15z.py b/migrations/public/versions/167d821471ed_2024_07_04t09_42_15z.py new file mode 100644 index 0000000..2123b23 --- /dev/null +++ b/migrations/public/versions/167d821471ed_2024_07_04t09_42_15z.py @@ -0,0 +1,62 @@ +"""2024-07-04T09:42:15Z + +Revision ID: 167d821471ed +Revises: e76f189a6489 +Create Date: 2024-07-04 09:42:16.959346 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '167d821471ed' +down_revision = 'e76f189a6489' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('roles_users', schema=None) as batch_op: + batch_op.drop_constraint('roles_users_user_id_fkey', type_='foreignkey') + batch_op.drop_constraint('roles_users_role_id_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'user', ['user_id'], ['id'], referent_schema='public', ondelete='CASCADE') + batch_op.create_foreign_key(None, 'role', ['role_id'], ['id'], referent_schema='public', ondelete='CASCADE') + + with op.batch_alter_table('tenant_domain', schema=None) as batch_op: + batch_op.drop_constraint('tenant_domain_created_by_fkey', type_='foreignkey') + batch_op.drop_constraint('tenant_domain_updated_by_fkey', type_='foreignkey') + batch_op.drop_constraint('tenant_domain_tenant_id_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'user', ['updated_by'], ['id'], referent_schema='public') + batch_op.create_foreign_key(None, 'tenant', ['tenant_id'], ['id'], referent_schema='public') + batch_op.create_foreign_key(None, 'user', ['created_by'], ['id'], referent_schema='public') + + with op.batch_alter_table('user', schema=None) as batch_op: + batch_op.drop_constraint('user_tenant_id_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'tenant', ['tenant_id'], ['id'], referent_schema='public') + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('user', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('user_tenant_id_fkey', 'tenant', ['tenant_id'], ['id']) + + with op.batch_alter_table('tenant_domain', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('tenant_domain_tenant_id_fkey', 'tenant', ['tenant_id'], ['id']) + batch_op.create_foreign_key('tenant_domain_updated_by_fkey', 'user', ['updated_by'], ['id']) + batch_op.create_foreign_key('tenant_domain_created_by_fkey', 'user', ['created_by'], ['id']) + + with op.batch_alter_table('roles_users', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('roles_users_role_id_fkey', 'role', ['role_id'], ['id'], ondelete='CASCADE') + batch_op.create_foreign_key('roles_users_user_id_fkey', 'user', ['user_id'], ['id'], ondelete='CASCADE') + + # ### end Alembic commands ### diff --git a/migrations/public/versions/1751a5318d34_2024_07_04t09_21_49z.py b/migrations/public/versions/1751a5318d34_2024_07_04t09_21_49z.py new file mode 100644 index 0000000..3da2216 --- /dev/null +++ b/migrations/public/versions/1751a5318d34_2024_07_04t09_21_49z.py @@ -0,0 +1,62 @@ +"""2024-07-04T09:21:49Z + +Revision ID: 1751a5318d34 +Revises: df7bd57b7ae8 +Create Date: 2024-07-04 09:21:50.715334 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '1751a5318d34' +down_revision = 'df7bd57b7ae8' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('roles_users', schema=None) as batch_op: + batch_op.drop_constraint('roles_users_role_id_fkey', type_='foreignkey') + batch_op.drop_constraint('roles_users_user_id_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'role', ['role_id'], ['id'], referent_schema='public', ondelete='CASCADE') + batch_op.create_foreign_key(None, 'user', ['user_id'], ['id'], referent_schema='public', ondelete='CASCADE') + + with op.batch_alter_table('tenant_domain', schema=None) as batch_op: + batch_op.drop_constraint('tenant_domain_created_by_fkey', type_='foreignkey') + batch_op.drop_constraint('tenant_domain_updated_by_fkey', type_='foreignkey') + batch_op.drop_constraint('tenant_domain_tenant_id_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'tenant', ['tenant_id'], ['id'], referent_schema='public') + batch_op.create_foreign_key(None, 'user', ['updated_by'], ['id'], referent_schema='public') + batch_op.create_foreign_key(None, 'user', ['created_by'], ['id'], referent_schema='public') + + with op.batch_alter_table('user', schema=None) as batch_op: + batch_op.drop_constraint('user_tenant_id_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'tenant', ['tenant_id'], ['id'], referent_schema='public') + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('user', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('user_tenant_id_fkey', 'tenant', ['tenant_id'], ['id']) + + with op.batch_alter_table('tenant_domain', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('tenant_domain_tenant_id_fkey', 'tenant', ['tenant_id'], ['id']) + batch_op.create_foreign_key('tenant_domain_updated_by_fkey', 'user', ['updated_by'], ['id']) + batch_op.create_foreign_key('tenant_domain_created_by_fkey', 'user', ['created_by'], ['id']) + + with op.batch_alter_table('roles_users', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('roles_users_user_id_fkey', 'user', ['user_id'], ['id'], ondelete='CASCADE') + batch_op.create_foreign_key('roles_users_role_id_fkey', 'role', ['role_id'], ['id'], ondelete='CASCADE') + + # ### end Alembic commands ### diff --git a/migrations/public/versions/2a18dab7d1a4_2024_07_04t09_43_14z.py b/migrations/public/versions/2a18dab7d1a4_2024_07_04t09_43_14z.py new file mode 100644 index 0000000..d0de6d1 --- /dev/null +++ b/migrations/public/versions/2a18dab7d1a4_2024_07_04t09_43_14z.py @@ -0,0 +1,62 @@ +"""2024-07-04T09:43:14Z + +Revision ID: 2a18dab7d1a4 +Revises: 167d821471ed +Create Date: 2024-07-04 09:43:16.445891 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '2a18dab7d1a4' +down_revision = '167d821471ed' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('roles_users', schema=None) as batch_op: + batch_op.drop_constraint('roles_users_role_id_fkey', type_='foreignkey') + batch_op.drop_constraint('roles_users_user_id_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'user', ['user_id'], ['id'], referent_schema='public', ondelete='CASCADE') + batch_op.create_foreign_key(None, 'role', ['role_id'], ['id'], referent_schema='public', ondelete='CASCADE') + + with op.batch_alter_table('tenant_domain', schema=None) as batch_op: + batch_op.drop_constraint('tenant_domain_tenant_id_fkey', type_='foreignkey') + batch_op.drop_constraint('tenant_domain_updated_by_fkey', type_='foreignkey') + batch_op.drop_constraint('tenant_domain_created_by_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'user', ['created_by'], ['id'], referent_schema='public') + batch_op.create_foreign_key(None, 'tenant', ['tenant_id'], ['id'], referent_schema='public') + batch_op.create_foreign_key(None, 'user', ['updated_by'], ['id'], referent_schema='public') + + with op.batch_alter_table('user', schema=None) as batch_op: + batch_op.drop_constraint('user_tenant_id_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'tenant', ['tenant_id'], ['id'], referent_schema='public') + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('user', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('user_tenant_id_fkey', 'tenant', ['tenant_id'], ['id']) + + with op.batch_alter_table('tenant_domain', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('tenant_domain_created_by_fkey', 'user', ['created_by'], ['id']) + batch_op.create_foreign_key('tenant_domain_updated_by_fkey', 'user', ['updated_by'], ['id']) + batch_op.create_foreign_key('tenant_domain_tenant_id_fkey', 'tenant', ['tenant_id'], ['id']) + + with op.batch_alter_table('roles_users', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('roles_users_user_id_fkey', 'user', ['user_id'], ['id'], ondelete='CASCADE') + batch_op.create_foreign_key('roles_users_role_id_fkey', 'role', ['role_id'], ['id'], ondelete='CASCADE') + + # ### end Alembic commands ### diff --git a/migrations/public/versions/38b9e73d847f_2024_07_04t09_38_14z.py b/migrations/public/versions/38b9e73d847f_2024_07_04t09_38_14z.py new file mode 100644 index 0000000..f07904e --- /dev/null +++ b/migrations/public/versions/38b9e73d847f_2024_07_04t09_38_14z.py @@ -0,0 +1,62 @@ +"""2024-07-04T09:38:14Z + +Revision ID: 38b9e73d847f +Revises: d93eab8ce138 +Create Date: 2024-07-04 09:38:16.081254 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '38b9e73d847f' +down_revision = 'd93eab8ce138' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('roles_users', schema=None) as batch_op: + batch_op.drop_constraint('roles_users_role_id_fkey', type_='foreignkey') + batch_op.drop_constraint('roles_users_user_id_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'user', ['user_id'], ['id'], referent_schema='public', ondelete='CASCADE') + batch_op.create_foreign_key(None, 'role', ['role_id'], ['id'], referent_schema='public', ondelete='CASCADE') + + with op.batch_alter_table('tenant_domain', schema=None) as batch_op: + batch_op.drop_constraint('tenant_domain_tenant_id_fkey', type_='foreignkey') + batch_op.drop_constraint('tenant_domain_created_by_fkey', type_='foreignkey') + batch_op.drop_constraint('tenant_domain_updated_by_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'user', ['updated_by'], ['id'], referent_schema='public') + batch_op.create_foreign_key(None, 'user', ['created_by'], ['id'], referent_schema='public') + batch_op.create_foreign_key(None, 'tenant', ['tenant_id'], ['id'], referent_schema='public') + + with op.batch_alter_table('user', schema=None) as batch_op: + batch_op.drop_constraint('user_tenant_id_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'tenant', ['tenant_id'], ['id'], referent_schema='public') + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('user', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('user_tenant_id_fkey', 'tenant', ['tenant_id'], ['id']) + + with op.batch_alter_table('tenant_domain', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('tenant_domain_updated_by_fkey', 'user', ['updated_by'], ['id']) + batch_op.create_foreign_key('tenant_domain_created_by_fkey', 'user', ['created_by'], ['id']) + batch_op.create_foreign_key('tenant_domain_tenant_id_fkey', 'tenant', ['tenant_id'], ['id']) + + with op.batch_alter_table('roles_users', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('roles_users_user_id_fkey', 'user', ['user_id'], ['id'], ondelete='CASCADE') + batch_op.create_foreign_key('roles_users_role_id_fkey', 'role', ['role_id'], ['id'], ondelete='CASCADE') + + # ### end Alembic commands ### diff --git a/migrations/public/versions/668e4a1000cb_2024_07_04t12_47_41z.py b/migrations/public/versions/668e4a1000cb_2024_07_04t12_47_41z.py new file mode 100644 index 0000000..a3093cc --- /dev/null +++ b/migrations/public/versions/668e4a1000cb_2024_07_04t12_47_41z.py @@ -0,0 +1,62 @@ +"""2024-07-04T12:47:41Z + +Revision ID: 668e4a1000cb +Revises: 89a287bbd574 +Create Date: 2024-07-04 12:47:42.696406 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '668e4a1000cb' +down_revision = '89a287bbd574' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('roles_users', schema=None) as batch_op: + batch_op.drop_constraint('roles_users_user_id_fkey', type_='foreignkey') + batch_op.drop_constraint('roles_users_role_id_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'user', ['user_id'], ['id'], referent_schema='public', ondelete='CASCADE') + batch_op.create_foreign_key(None, 'role', ['role_id'], ['id'], referent_schema='public', ondelete='CASCADE') + + with op.batch_alter_table('tenant_domain', schema=None) as batch_op: + batch_op.drop_constraint('tenant_domain_created_by_fkey', type_='foreignkey') + batch_op.drop_constraint('tenant_domain_tenant_id_fkey', type_='foreignkey') + batch_op.drop_constraint('tenant_domain_updated_by_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'user', ['updated_by'], ['id'], referent_schema='public') + batch_op.create_foreign_key(None, 'user', ['created_by'], ['id'], referent_schema='public') + batch_op.create_foreign_key(None, 'tenant', ['tenant_id'], ['id'], referent_schema='public') + + with op.batch_alter_table('user', schema=None) as batch_op: + batch_op.drop_constraint('user_tenant_id_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'tenant', ['tenant_id'], ['id'], referent_schema='public') + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('user', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('user_tenant_id_fkey', 'tenant', ['tenant_id'], ['id']) + + with op.batch_alter_table('tenant_domain', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('tenant_domain_updated_by_fkey', 'user', ['updated_by'], ['id']) + batch_op.create_foreign_key('tenant_domain_tenant_id_fkey', 'tenant', ['tenant_id'], ['id']) + batch_op.create_foreign_key('tenant_domain_created_by_fkey', 'user', ['created_by'], ['id']) + + with op.batch_alter_table('roles_users', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('roles_users_role_id_fkey', 'role', ['role_id'], ['id'], ondelete='CASCADE') + batch_op.create_foreign_key('roles_users_user_id_fkey', 'user', ['user_id'], ['id'], ondelete='CASCADE') + + # ### end Alembic commands ### diff --git a/migrations/public/versions/89a287bbd574_2024_07_04t12_28_00z.py b/migrations/public/versions/89a287bbd574_2024_07_04t12_28_00z.py new file mode 100644 index 0000000..4de1407 --- /dev/null +++ b/migrations/public/versions/89a287bbd574_2024_07_04t12_28_00z.py @@ -0,0 +1,62 @@ +"""2024-07-04T12:28:00Z + +Revision ID: 89a287bbd574 +Revises: cda254aa11ec +Create Date: 2024-07-04 12:28:01.628253 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '89a287bbd574' +down_revision = 'cda254aa11ec' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('roles_users', schema=None) as batch_op: + batch_op.drop_constraint('roles_users_role_id_fkey', type_='foreignkey') + batch_op.drop_constraint('roles_users_user_id_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'role', ['role_id'], ['id'], referent_schema='public', ondelete='CASCADE') + batch_op.create_foreign_key(None, 'user', ['user_id'], ['id'], referent_schema='public', ondelete='CASCADE') + + with op.batch_alter_table('tenant_domain', schema=None) as batch_op: + batch_op.drop_constraint('tenant_domain_created_by_fkey', type_='foreignkey') + batch_op.drop_constraint('tenant_domain_updated_by_fkey', type_='foreignkey') + batch_op.drop_constraint('tenant_domain_tenant_id_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'user', ['created_by'], ['id'], referent_schema='public') + batch_op.create_foreign_key(None, 'user', ['updated_by'], ['id'], referent_schema='public') + batch_op.create_foreign_key(None, 'tenant', ['tenant_id'], ['id'], referent_schema='public') + + with op.batch_alter_table('user', schema=None) as batch_op: + batch_op.drop_constraint('user_tenant_id_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'tenant', ['tenant_id'], ['id'], referent_schema='public') + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('user', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('user_tenant_id_fkey', 'tenant', ['tenant_id'], ['id']) + + with op.batch_alter_table('tenant_domain', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('tenant_domain_tenant_id_fkey', 'tenant', ['tenant_id'], ['id']) + batch_op.create_foreign_key('tenant_domain_updated_by_fkey', 'user', ['updated_by'], ['id']) + batch_op.create_foreign_key('tenant_domain_created_by_fkey', 'user', ['created_by'], ['id']) + + with op.batch_alter_table('roles_users', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('roles_users_user_id_fkey', 'user', ['user_id'], ['id'], ondelete='CASCADE') + batch_op.create_foreign_key('roles_users_role_id_fkey', 'role', ['role_id'], ['id'], ondelete='CASCADE') + + # ### end Alembic commands ### diff --git a/migrations/public/versions/8ab72fe23ee4_2024_07_04t12_51_36z.py b/migrations/public/versions/8ab72fe23ee4_2024_07_04t12_51_36z.py new file mode 100644 index 0000000..11cfce3 --- /dev/null +++ b/migrations/public/versions/8ab72fe23ee4_2024_07_04t12_51_36z.py @@ -0,0 +1,62 @@ +"""2024-07-04T12:51:36Z + +Revision ID: 8ab72fe23ee4 +Revises: 668e4a1000cb +Create Date: 2024-07-04 12:51:37.394042 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '8ab72fe23ee4' +down_revision = '668e4a1000cb' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('roles_users', schema=None) as batch_op: + batch_op.drop_constraint('roles_users_user_id_fkey', type_='foreignkey') + batch_op.drop_constraint('roles_users_role_id_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'role', ['role_id'], ['id'], referent_schema='public', ondelete='CASCADE') + batch_op.create_foreign_key(None, 'user', ['user_id'], ['id'], referent_schema='public', ondelete='CASCADE') + + with op.batch_alter_table('tenant_domain', schema=None) as batch_op: + batch_op.drop_constraint('tenant_domain_updated_by_fkey', type_='foreignkey') + batch_op.drop_constraint('tenant_domain_created_by_fkey', type_='foreignkey') + batch_op.drop_constraint('tenant_domain_tenant_id_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'user', ['updated_by'], ['id'], referent_schema='public') + batch_op.create_foreign_key(None, 'tenant', ['tenant_id'], ['id'], referent_schema='public') + batch_op.create_foreign_key(None, 'user', ['created_by'], ['id'], referent_schema='public') + + with op.batch_alter_table('user', schema=None) as batch_op: + batch_op.drop_constraint('user_tenant_id_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'tenant', ['tenant_id'], ['id'], referent_schema='public') + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('user', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('user_tenant_id_fkey', 'tenant', ['tenant_id'], ['id']) + + with op.batch_alter_table('tenant_domain', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('tenant_domain_tenant_id_fkey', 'tenant', ['tenant_id'], ['id']) + batch_op.create_foreign_key('tenant_domain_created_by_fkey', 'user', ['created_by'], ['id']) + batch_op.create_foreign_key('tenant_domain_updated_by_fkey', 'user', ['updated_by'], ['id']) + + with op.batch_alter_table('roles_users', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('roles_users_role_id_fkey', 'role', ['role_id'], ['id'], ondelete='CASCADE') + batch_op.create_foreign_key('roles_users_user_id_fkey', 'user', ['user_id'], ['id'], ondelete='CASCADE') + + # ### end Alembic commands ### diff --git a/migrations/public/versions/cda254aa11ec_2024_07_04t09_59_04z.py b/migrations/public/versions/cda254aa11ec_2024_07_04t09_59_04z.py new file mode 100644 index 0000000..bd3f22b --- /dev/null +++ b/migrations/public/versions/cda254aa11ec_2024_07_04t09_59_04z.py @@ -0,0 +1,62 @@ +"""2024-07-04T09:59:04Z + +Revision ID: cda254aa11ec +Revises: 2a18dab7d1a4 +Create Date: 2024-07-04 09:59:05.543007 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'cda254aa11ec' +down_revision = '2a18dab7d1a4' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('roles_users', schema=None) as batch_op: + batch_op.drop_constraint('roles_users_role_id_fkey', type_='foreignkey') + batch_op.drop_constraint('roles_users_user_id_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'user', ['user_id'], ['id'], referent_schema='public', ondelete='CASCADE') + batch_op.create_foreign_key(None, 'role', ['role_id'], ['id'], referent_schema='public', ondelete='CASCADE') + + with op.batch_alter_table('tenant_domain', schema=None) as batch_op: + batch_op.drop_constraint('tenant_domain_tenant_id_fkey', type_='foreignkey') + batch_op.drop_constraint('tenant_domain_updated_by_fkey', type_='foreignkey') + batch_op.drop_constraint('tenant_domain_created_by_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'tenant', ['tenant_id'], ['id'], referent_schema='public') + batch_op.create_foreign_key(None, 'user', ['created_by'], ['id'], referent_schema='public') + batch_op.create_foreign_key(None, 'user', ['updated_by'], ['id'], referent_schema='public') + + with op.batch_alter_table('user', schema=None) as batch_op: + batch_op.drop_constraint('user_tenant_id_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'tenant', ['tenant_id'], ['id'], referent_schema='public') + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('user', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('user_tenant_id_fkey', 'tenant', ['tenant_id'], ['id']) + + with op.batch_alter_table('tenant_domain', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('tenant_domain_created_by_fkey', 'user', ['created_by'], ['id']) + batch_op.create_foreign_key('tenant_domain_updated_by_fkey', 'user', ['updated_by'], ['id']) + batch_op.create_foreign_key('tenant_domain_tenant_id_fkey', 'tenant', ['tenant_id'], ['id']) + + with op.batch_alter_table('roles_users', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('roles_users_user_id_fkey', 'user', ['user_id'], ['id'], ondelete='CASCADE') + batch_op.create_foreign_key('roles_users_role_id_fkey', 'role', ['role_id'], ['id'], ondelete='CASCADE') + + # ### end Alembic commands ### diff --git a/migrations/public/versions/d93eab8ce138_2024_07_04t09_36_42z.py b/migrations/public/versions/d93eab8ce138_2024_07_04t09_36_42z.py new file mode 100644 index 0000000..a90e323 --- /dev/null +++ b/migrations/public/versions/d93eab8ce138_2024_07_04t09_36_42z.py @@ -0,0 +1,62 @@ +"""2024-07-04T09:36:42Z + +Revision ID: d93eab8ce138 +Revises: ff206102492b +Create Date: 2024-07-04 09:36:44.423035 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'd93eab8ce138' +down_revision = 'ff206102492b' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('roles_users', schema=None) as batch_op: + batch_op.drop_constraint('roles_users_role_id_fkey', type_='foreignkey') + batch_op.drop_constraint('roles_users_user_id_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'user', ['user_id'], ['id'], referent_schema='public', ondelete='CASCADE') + batch_op.create_foreign_key(None, 'role', ['role_id'], ['id'], referent_schema='public', ondelete='CASCADE') + + with op.batch_alter_table('tenant_domain', schema=None) as batch_op: + batch_op.drop_constraint('tenant_domain_tenant_id_fkey', type_='foreignkey') + batch_op.drop_constraint('tenant_domain_created_by_fkey', type_='foreignkey') + batch_op.drop_constraint('tenant_domain_updated_by_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'tenant', ['tenant_id'], ['id'], referent_schema='public') + batch_op.create_foreign_key(None, 'user', ['created_by'], ['id'], referent_schema='public') + batch_op.create_foreign_key(None, 'user', ['updated_by'], ['id'], referent_schema='public') + + with op.batch_alter_table('user', schema=None) as batch_op: + batch_op.drop_constraint('user_tenant_id_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'tenant', ['tenant_id'], ['id'], referent_schema='public') + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('user', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('user_tenant_id_fkey', 'tenant', ['tenant_id'], ['id']) + + with op.batch_alter_table('tenant_domain', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('tenant_domain_updated_by_fkey', 'user', ['updated_by'], ['id']) + batch_op.create_foreign_key('tenant_domain_created_by_fkey', 'user', ['created_by'], ['id']) + batch_op.create_foreign_key('tenant_domain_tenant_id_fkey', 'tenant', ['tenant_id'], ['id']) + + with op.batch_alter_table('roles_users', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('roles_users_user_id_fkey', 'user', ['user_id'], ['id'], ondelete='CASCADE') + batch_op.create_foreign_key('roles_users_role_id_fkey', 'role', ['role_id'], ['id'], ondelete='CASCADE') + + # ### end Alembic commands ### diff --git a/migrations/public/versions/df7bd57b7ae8_2024_07_04t09_08_45z.py b/migrations/public/versions/df7bd57b7ae8_2024_07_04t09_08_45z.py new file mode 100644 index 0000000..cac97de --- /dev/null +++ b/migrations/public/versions/df7bd57b7ae8_2024_07_04t09_08_45z.py @@ -0,0 +1,62 @@ +"""2024-07-04T09:08:45Z + +Revision ID: df7bd57b7ae8 +Revises: edb5953e3438 +Create Date: 2024-07-04 09:08:47.284217 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'df7bd57b7ae8' +down_revision = 'edb5953e3438' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('roles_users', schema=None) as batch_op: + batch_op.drop_constraint('roles_users_role_id_fkey', type_='foreignkey') + batch_op.drop_constraint('roles_users_user_id_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'user', ['user_id'], ['id'], referent_schema='public', ondelete='CASCADE') + batch_op.create_foreign_key(None, 'role', ['role_id'], ['id'], referent_schema='public', ondelete='CASCADE') + + with op.batch_alter_table('tenant_domain', schema=None) as batch_op: + batch_op.drop_constraint('tenant_domain_updated_by_fkey', type_='foreignkey') + batch_op.drop_constraint('tenant_domain_tenant_id_fkey', type_='foreignkey') + batch_op.drop_constraint('tenant_domain_created_by_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'user', ['created_by'], ['id'], referent_schema='public') + batch_op.create_foreign_key(None, 'tenant', ['tenant_id'], ['id'], referent_schema='public') + batch_op.create_foreign_key(None, 'user', ['updated_by'], ['id'], referent_schema='public') + + with op.batch_alter_table('user', schema=None) as batch_op: + batch_op.drop_constraint('user_tenant_id_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'tenant', ['tenant_id'], ['id'], referent_schema='public') + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('user', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('user_tenant_id_fkey', 'tenant', ['tenant_id'], ['id']) + + with op.batch_alter_table('tenant_domain', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('tenant_domain_created_by_fkey', 'user', ['created_by'], ['id']) + batch_op.create_foreign_key('tenant_domain_tenant_id_fkey', 'tenant', ['tenant_id'], ['id']) + batch_op.create_foreign_key('tenant_domain_updated_by_fkey', 'user', ['updated_by'], ['id']) + + with op.batch_alter_table('roles_users', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('roles_users_user_id_fkey', 'user', ['user_id'], ['id'], ondelete='CASCADE') + batch_op.create_foreign_key('roles_users_role_id_fkey', 'role', ['role_id'], ['id'], ondelete='CASCADE') + + # ### end Alembic commands ### diff --git a/migrations/public/versions/e76f189a6489_2024_07_04t09_40_45z.py b/migrations/public/versions/e76f189a6489_2024_07_04t09_40_45z.py new file mode 100644 index 0000000..cacb729 --- /dev/null +++ b/migrations/public/versions/e76f189a6489_2024_07_04t09_40_45z.py @@ -0,0 +1,62 @@ +"""2024-07-04T09:40:45Z + +Revision ID: e76f189a6489 +Revises: 38b9e73d847f +Create Date: 2024-07-04 09:40:46.984037 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'e76f189a6489' +down_revision = '38b9e73d847f' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('roles_users', schema=None) as batch_op: + batch_op.drop_constraint('roles_users_role_id_fkey', type_='foreignkey') + batch_op.drop_constraint('roles_users_user_id_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'user', ['user_id'], ['id'], referent_schema='public', ondelete='CASCADE') + batch_op.create_foreign_key(None, 'role', ['role_id'], ['id'], referent_schema='public', ondelete='CASCADE') + + with op.batch_alter_table('tenant_domain', schema=None) as batch_op: + batch_op.drop_constraint('tenant_domain_updated_by_fkey', type_='foreignkey') + batch_op.drop_constraint('tenant_domain_created_by_fkey', type_='foreignkey') + batch_op.drop_constraint('tenant_domain_tenant_id_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'tenant', ['tenant_id'], ['id'], referent_schema='public') + batch_op.create_foreign_key(None, 'user', ['created_by'], ['id'], referent_schema='public') + batch_op.create_foreign_key(None, 'user', ['updated_by'], ['id'], referent_schema='public') + + with op.batch_alter_table('user', schema=None) as batch_op: + batch_op.drop_constraint('user_tenant_id_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'tenant', ['tenant_id'], ['id'], referent_schema='public') + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('user', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('user_tenant_id_fkey', 'tenant', ['tenant_id'], ['id']) + + with op.batch_alter_table('tenant_domain', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('tenant_domain_tenant_id_fkey', 'tenant', ['tenant_id'], ['id']) + batch_op.create_foreign_key('tenant_domain_created_by_fkey', 'user', ['created_by'], ['id']) + batch_op.create_foreign_key('tenant_domain_updated_by_fkey', 'user', ['updated_by'], ['id']) + + with op.batch_alter_table('roles_users', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('roles_users_user_id_fkey', 'user', ['user_id'], ['id'], ondelete='CASCADE') + batch_op.create_foreign_key('roles_users_role_id_fkey', 'role', ['role_id'], ['id'], ondelete='CASCADE') + + # ### end Alembic commands ### diff --git a/migrations/public/versions/edb5953e3438_2024_07_04t08_18_50z.py b/migrations/public/versions/edb5953e3438_2024_07_04t08_18_50z.py new file mode 100644 index 0000000..b733304 --- /dev/null +++ b/migrations/public/versions/edb5953e3438_2024_07_04t08_18_50z.py @@ -0,0 +1,62 @@ +"""2024-07-04T08:18:50Z + +Revision ID: edb5953e3438 +Revises: fdc9ac232c49 +Create Date: 2024-07-04 08:18:51.422112 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'edb5953e3438' +down_revision = 'fdc9ac232c49' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('roles_users', schema=None) as batch_op: + batch_op.drop_constraint('roles_users_role_id_fkey', type_='foreignkey') + batch_op.drop_constraint('roles_users_user_id_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'role', ['role_id'], ['id'], referent_schema='public', ondelete='CASCADE') + batch_op.create_foreign_key(None, 'user', ['user_id'], ['id'], referent_schema='public', ondelete='CASCADE') + + with op.batch_alter_table('tenant_domain', schema=None) as batch_op: + batch_op.drop_constraint('tenant_domain_updated_by_fkey', type_='foreignkey') + batch_op.drop_constraint('tenant_domain_created_by_fkey', type_='foreignkey') + batch_op.drop_constraint('tenant_domain_tenant_id_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'user', ['updated_by'], ['id'], referent_schema='public') + batch_op.create_foreign_key(None, 'user', ['created_by'], ['id'], referent_schema='public') + batch_op.create_foreign_key(None, 'tenant', ['tenant_id'], ['id'], referent_schema='public') + + with op.batch_alter_table('user', schema=None) as batch_op: + batch_op.drop_constraint('user_tenant_id_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'tenant', ['tenant_id'], ['id'], referent_schema='public') + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('user', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('user_tenant_id_fkey', 'tenant', ['tenant_id'], ['id']) + + with op.batch_alter_table('tenant_domain', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('tenant_domain_tenant_id_fkey', 'tenant', ['tenant_id'], ['id']) + batch_op.create_foreign_key('tenant_domain_created_by_fkey', 'user', ['created_by'], ['id']) + batch_op.create_foreign_key('tenant_domain_updated_by_fkey', 'user', ['updated_by'], ['id']) + + with op.batch_alter_table('roles_users', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('roles_users_user_id_fkey', 'user', ['user_id'], ['id'], ondelete='CASCADE') + batch_op.create_foreign_key('roles_users_role_id_fkey', 'role', ['role_id'], ['id'], ondelete='CASCADE') + + # ### end Alembic commands ### diff --git a/migrations/public/versions/fdc9ac232c49_2024_07_04t07_39_16z.py b/migrations/public/versions/fdc9ac232c49_2024_07_04t07_39_16z.py new file mode 100644 index 0000000..454dc2a --- /dev/null +++ b/migrations/public/versions/fdc9ac232c49_2024_07_04t07_39_16z.py @@ -0,0 +1,62 @@ +"""2024-07-04T07:39:16Z + +Revision ID: fdc9ac232c49 +Revises: 358bb5f8ebf1 +Create Date: 2024-07-04 07:39:18.468658 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'fdc9ac232c49' +down_revision = '358bb5f8ebf1' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('roles_users', schema=None) as batch_op: + batch_op.drop_constraint('roles_users_user_id_fkey', type_='foreignkey') + batch_op.drop_constraint('roles_users_role_id_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'role', ['role_id'], ['id'], referent_schema='public', ondelete='CASCADE') + batch_op.create_foreign_key(None, 'user', ['user_id'], ['id'], referent_schema='public', ondelete='CASCADE') + + with op.batch_alter_table('tenant_domain', schema=None) as batch_op: + batch_op.drop_constraint('tenant_domain_updated_by_fkey', type_='foreignkey') + batch_op.drop_constraint('tenant_domain_created_by_fkey', type_='foreignkey') + batch_op.drop_constraint('tenant_domain_tenant_id_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'user', ['updated_by'], ['id'], referent_schema='public') + batch_op.create_foreign_key(None, 'user', ['created_by'], ['id'], referent_schema='public') + batch_op.create_foreign_key(None, 'tenant', ['tenant_id'], ['id'], referent_schema='public') + + with op.batch_alter_table('user', schema=None) as batch_op: + batch_op.drop_constraint('user_tenant_id_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'tenant', ['tenant_id'], ['id'], referent_schema='public') + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('user', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('user_tenant_id_fkey', 'tenant', ['tenant_id'], ['id']) + + with op.batch_alter_table('tenant_domain', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('tenant_domain_tenant_id_fkey', 'tenant', ['tenant_id'], ['id']) + batch_op.create_foreign_key('tenant_domain_created_by_fkey', 'user', ['created_by'], ['id']) + batch_op.create_foreign_key('tenant_domain_updated_by_fkey', 'user', ['updated_by'], ['id']) + + with op.batch_alter_table('roles_users', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('roles_users_role_id_fkey', 'role', ['role_id'], ['id'], ondelete='CASCADE') + batch_op.create_foreign_key('roles_users_user_id_fkey', 'user', ['user_id'], ['id'], ondelete='CASCADE') + + # ### end Alembic commands ### diff --git a/migrations/public/versions/ff206102492b_2024_07_04t09_28_42z.py b/migrations/public/versions/ff206102492b_2024_07_04t09_28_42z.py new file mode 100644 index 0000000..e2ca441 --- /dev/null +++ b/migrations/public/versions/ff206102492b_2024_07_04t09_28_42z.py @@ -0,0 +1,62 @@ +"""2024-07-04T09:28:42Z + +Revision ID: ff206102492b +Revises: 1751a5318d34 +Create Date: 2024-07-04 09:28:44.437097 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'ff206102492b' +down_revision = '1751a5318d34' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('roles_users', schema=None) as batch_op: + batch_op.drop_constraint('roles_users_role_id_fkey', type_='foreignkey') + batch_op.drop_constraint('roles_users_user_id_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'user', ['user_id'], ['id'], referent_schema='public', ondelete='CASCADE') + batch_op.create_foreign_key(None, 'role', ['role_id'], ['id'], referent_schema='public', ondelete='CASCADE') + + with op.batch_alter_table('tenant_domain', schema=None) as batch_op: + batch_op.drop_constraint('tenant_domain_tenant_id_fkey', type_='foreignkey') + batch_op.drop_constraint('tenant_domain_updated_by_fkey', type_='foreignkey') + batch_op.drop_constraint('tenant_domain_created_by_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'user', ['updated_by'], ['id'], referent_schema='public') + batch_op.create_foreign_key(None, 'tenant', ['tenant_id'], ['id'], referent_schema='public') + batch_op.create_foreign_key(None, 'user', ['created_by'], ['id'], referent_schema='public') + + with op.batch_alter_table('user', schema=None) as batch_op: + batch_op.drop_constraint('user_tenant_id_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'tenant', ['tenant_id'], ['id'], referent_schema='public') + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('user', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('user_tenant_id_fkey', 'tenant', ['tenant_id'], ['id']) + + with op.batch_alter_table('tenant_domain', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('tenant_domain_created_by_fkey', 'user', ['created_by'], ['id']) + batch_op.create_foreign_key('tenant_domain_updated_by_fkey', 'user', ['updated_by'], ['id']) + batch_op.create_foreign_key('tenant_domain_tenant_id_fkey', 'tenant', ['tenant_id'], ['id']) + + with op.batch_alter_table('roles_users', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('roles_users_user_id_fkey', 'user', ['user_id'], ['id'], ondelete='CASCADE') + batch_op.create_foreign_key('roles_users_role_id_fkey', 'role', ['role_id'], ['id'], ondelete='CASCADE') + + # ### end Alembic commands ### diff --git a/migrations/tenant/.DS_Store b/migrations/tenant/.DS_Store index 0d35ada..5c2ccff 100644 Binary files a/migrations/tenant/.DS_Store and b/migrations/tenant/.DS_Store differ diff --git a/migrations/tenant/__pycache__/env.cpython-312.pyc b/migrations/tenant/__pycache__/env.cpython-312.pyc index 3b03445..fef0463 100644 Binary files a/migrations/tenant/__pycache__/env.cpython-312.pyc and b/migrations/tenant/__pycache__/env.cpython-312.pyc differ diff --git a/migrations/tenant/env.py b/migrations/tenant/env.py index 48031f6..7ca7306 100644 --- a/migrations/tenant/env.py +++ b/migrations/tenant/env.py @@ -99,6 +99,16 @@ def run_migrations_online(): poolclass=NullPool, ) + def process_revision_directives(context, revision, directives): + if config.cmd_opts.autogenerate: + script = directives[0] + if script.upgrade_ops is not None: + # Add import for pgvector and set search path + script.upgrade_ops.ops.insert(0, sa.schema.ExecuteSQLOp( + "SET search_path TO CURRENT_SCHEMA(), public; IMPORT pgvector", + execution_options=None + )) + with connectable.connect() as connection: print(tenants) for tenant in tenants: @@ -106,17 +116,18 @@ def run_migrations_online(): # set search path on the connection, which ensures that # PostgreSQL will emit all CREATE / ALTER / DROP statements # in terms of this schema by default - connection.execute(text(f'SET search_path TO "{tenant}"')) + connection.execute(text(f'SET search_path TO "{tenant}", public')) # in SQLAlchemy v2+ the search path change needs to be committed connection.commit() # make use of non-supported SQLAlchemy attribute to ensure # the dialect reflects tables in terms of the current tenant name - connection.dialect.default_schema_name = tenant + connection.dialect.default_schema_name = str(tenant) context.configure( connection=connection, target_metadata=get_metadata(), + process_revision_directives=process_revision_directives, ) with context.begin_transaction(): diff --git a/migrations/tenant/script.py.mako b/migrations/tenant/script.py.mako index 2c01563..a5f3613 100644 --- a/migrations/tenant/script.py.mako +++ b/migrations/tenant/script.py.mako @@ -7,6 +7,7 @@ Create Date: ${create_date} """ from alembic import op import sqlalchemy as sa +import pgvector ${imports if imports else ""} # revision identifiers, used by Alembic. diff --git a/migrations/tenant/versions/5d5437d81041_add_embedding_model_for_openai_large_.py b/migrations/tenant/versions/5d5437d81041_add_embedding_model_for_openai_large_.py new file mode 100644 index 0000000..a93651b --- /dev/null +++ b/migrations/tenant/versions/5d5437d81041_add_embedding_model_for_openai_large_.py @@ -0,0 +1,34 @@ +"""Add Embedding model for OpenAI large model + +Revision ID: 5d5437d81041 +Revises: d173cea8d204 +Create Date: 2024-07-04 15:49:43.665685 + +""" +from alembic import op +import sqlalchemy as sa +import pgvector + + +# revision identifiers, used by Alembic. +revision = '5d5437d81041' +down_revision = 'd173cea8d204' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('embedding_large_openai', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('embedding', pgvector.sqlalchemy.Vector(dim=3072), nullable=False), + sa.ForeignKeyConstraint(['id'], ['embeddings.id'], ), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('embedding_large_openai') + # ### end Alembic commands ### diff --git a/migrations/tenant/versions/__pycache__/217938792642_removing_documentlanguage_user_context_.cpython-312.pyc b/migrations/tenant/versions/__pycache__/217938792642_removing_documentlanguage_user_context_.cpython-312.pyc index dcb41b4..ddc62de 100644 Binary files a/migrations/tenant/versions/__pycache__/217938792642_removing_documentlanguage_user_context_.cpython-312.pyc and b/migrations/tenant/versions/__pycache__/217938792642_removing_documentlanguage_user_context_.cpython-312.pyc differ diff --git a/migrations/tenant/versions/__pycache__/324ed734ed9b_chunking_information_added_to_document_.cpython-312.pyc b/migrations/tenant/versions/__pycache__/324ed734ed9b_chunking_information_added_to_document_.cpython-312.pyc index bd9adc5..9e7d126 100644 Binary files a/migrations/tenant/versions/__pycache__/324ed734ed9b_chunking_information_added_to_document_.cpython-312.pyc and b/migrations/tenant/versions/__pycache__/324ed734ed9b_chunking_information_added_to_document_.cpython-312.pyc differ diff --git a/migrations/tenant/versions/__pycache__/3bc7bbed1ec6_ensure_latest_version_id_is_nullable.cpython-312.pyc b/migrations/tenant/versions/__pycache__/3bc7bbed1ec6_ensure_latest_version_id_is_nullable.cpython-312.pyc index 80beadc..ce37c6f 100644 Binary files a/migrations/tenant/versions/__pycache__/3bc7bbed1ec6_ensure_latest_version_id_is_nullable.cpython-312.pyc and b/migrations/tenant/versions/__pycache__/3bc7bbed1ec6_ensure_latest_version_id_is_nullable.cpython-312.pyc differ diff --git a/migrations/tenant/versions/__pycache__/45620002ae0d_additional_processing_fields_added_to_.cpython-312.pyc b/migrations/tenant/versions/__pycache__/45620002ae0d_additional_processing_fields_added_to_.cpython-312.pyc index f166935..b23bc19 100644 Binary files a/migrations/tenant/versions/__pycache__/45620002ae0d_additional_processing_fields_added_to_.cpython-312.pyc and b/migrations/tenant/versions/__pycache__/45620002ae0d_additional_processing_fields_added_to_.cpython-312.pyc differ diff --git a/migrations/tenant/versions/__pycache__/4f22dd6260e3_embeddings_for_openai.cpython-312.pyc b/migrations/tenant/versions/__pycache__/4f22dd6260e3_embeddings_for_openai.cpython-312.pyc index 0df5db2..4923fd9 100644 Binary files a/migrations/tenant/versions/__pycache__/4f22dd6260e3_embeddings_for_openai.cpython-312.pyc and b/migrations/tenant/versions/__pycache__/4f22dd6260e3_embeddings_for_openai.cpython-312.pyc differ diff --git a/migrations/tenant/versions/__pycache__/505b61314bba_defined_interaction_domain.cpython-312.pyc b/migrations/tenant/versions/__pycache__/505b61314bba_defined_interaction_domain.cpython-312.pyc index 8277f77..d01f0fe 100644 Binary files a/migrations/tenant/versions/__pycache__/505b61314bba_defined_interaction_domain.cpython-312.pyc and b/migrations/tenant/versions/__pycache__/505b61314bba_defined_interaction_domain.cpython-312.pyc differ diff --git a/migrations/tenant/versions/__pycache__/53fee8f13cdb_defined_interaction_domain_2.cpython-312.pyc b/migrations/tenant/versions/__pycache__/53fee8f13cdb_defined_interaction_domain_2.cpython-312.pyc index 924e4f8..7a7c284 100644 Binary files a/migrations/tenant/versions/__pycache__/53fee8f13cdb_defined_interaction_domain_2.cpython-312.pyc and b/migrations/tenant/versions/__pycache__/53fee8f13cdb_defined_interaction_domain_2.cpython-312.pyc differ diff --git a/migrations/tenant/versions/__pycache__/5c67abd3b371_add_caching_for_latest_version_in_.cpython-312.pyc b/migrations/tenant/versions/__pycache__/5c67abd3b371_add_caching_for_latest_version_in_.cpython-312.pyc index cdfdba5..12e8790 100644 Binary files a/migrations/tenant/versions/__pycache__/5c67abd3b371_add_caching_for_latest_version_in_.cpython-312.pyc and b/migrations/tenant/versions/__pycache__/5c67abd3b371_add_caching_for_latest_version_in_.cpython-312.pyc differ diff --git a/migrations/tenant/versions/__pycache__/5d5437d81041_add_embedding_model_for_openai_large_.cpython-312.pyc b/migrations/tenant/versions/__pycache__/5d5437d81041_add_embedding_model_for_openai_large_.cpython-312.pyc new file mode 100644 index 0000000..8f822fb Binary files /dev/null and b/migrations/tenant/versions/__pycache__/5d5437d81041_add_embedding_model_for_openai_large_.cpython-312.pyc differ diff --git a/migrations/tenant/versions/__pycache__/6fbceab656a8_adding_algorithm_information_in_the_.cpython-312.pyc b/migrations/tenant/versions/__pycache__/6fbceab656a8_adding_algorithm_information_in_the_.cpython-312.pyc index ae24acc..eea460b 100644 Binary files a/migrations/tenant/versions/__pycache__/6fbceab656a8_adding_algorithm_information_in_the_.cpython-312.pyc and b/migrations/tenant/versions/__pycache__/6fbceab656a8_adding_algorithm_information_in_the_.cpython-312.pyc differ diff --git a/migrations/tenant/versions/__pycache__/83b4a2aedbf1_initial_document_models_added.cpython-312.pyc b/migrations/tenant/versions/__pycache__/83b4a2aedbf1_initial_document_models_added.cpython-312.pyc index 756f754..920338c 100644 Binary files a/migrations/tenant/versions/__pycache__/83b4a2aedbf1_initial_document_models_added.cpython-312.pyc and b/migrations/tenant/versions/__pycache__/83b4a2aedbf1_initial_document_models_added.cpython-312.pyc differ diff --git a/migrations/tenant/versions/__pycache__/a3f3f5eaa3de_adding_detailed_question_information_to_.cpython-312.pyc b/migrations/tenant/versions/__pycache__/a3f3f5eaa3de_adding_detailed_question_information_to_.cpython-312.pyc index c21a38f..a37271f 100644 Binary files a/migrations/tenant/versions/__pycache__/a3f3f5eaa3de_adding_detailed_question_information_to_.cpython-312.pyc and b/migrations/tenant/versions/__pycache__/a3f3f5eaa3de_adding_detailed_question_information_to_.cpython-312.pyc differ diff --git a/migrations/tenant/versions/__pycache__/cb01c9192dc1_interaction_appreciation_should_be_null_.cpython-312.pyc b/migrations/tenant/versions/__pycache__/cb01c9192dc1_interaction_appreciation_should_be_null_.cpython-312.pyc index 7a06f47..4ee418c 100644 Binary files a/migrations/tenant/versions/__pycache__/cb01c9192dc1_interaction_appreciation_should_be_null_.cpython-312.pyc and b/migrations/tenant/versions/__pycache__/cb01c9192dc1_interaction_appreciation_should_be_null_.cpython-312.pyc differ diff --git a/migrations/tenant/versions/__pycache__/d173cea8d204_added_timezone_information_of_chat_user_.cpython-312.pyc b/migrations/tenant/versions/__pycache__/d173cea8d204_added_timezone_information_of_chat_user_.cpython-312.pyc index 335a01e..a0f5e48 100644 Binary files a/migrations/tenant/versions/__pycache__/d173cea8d204_added_timezone_information_of_chat_user_.cpython-312.pyc and b/migrations/tenant/versions/__pycache__/d173cea8d204_added_timezone_information_of_chat_user_.cpython-312.pyc differ diff --git a/migrations/tenant/versions/__pycache__/e2735d216d3c_defined_interaction_domain.cpython-312.pyc b/migrations/tenant/versions/__pycache__/e2735d216d3c_defined_interaction_domain.cpython-312.pyc index e88e258..da04751 100644 Binary files a/migrations/tenant/versions/__pycache__/e2735d216d3c_defined_interaction_domain.cpython-312.pyc and b/migrations/tenant/versions/__pycache__/e2735d216d3c_defined_interaction_domain.cpython-312.pyc differ diff --git a/migrations/tenant/versions/__pycache__/f5bbaed3a9ee_embeddings_according_to_pgvector_.cpython-312.pyc b/migrations/tenant/versions/__pycache__/f5bbaed3a9ee_embeddings_according_to_pgvector_.cpython-312.pyc index 299b4fd..2935c41 100644 Binary files a/migrations/tenant/versions/__pycache__/f5bbaed3a9ee_embeddings_according_to_pgvector_.cpython-312.pyc and b/migrations/tenant/versions/__pycache__/f5bbaed3a9ee_embeddings_according_to_pgvector_.cpython-312.pyc differ diff --git a/migrations/tenant/versions/__pycache__/f6ecc306055a_adding_session_id_to_chatsession.cpython-312.pyc b/migrations/tenant/versions/__pycache__/f6ecc306055a_adding_session_id_to_chatsession.cpython-312.pyc index 5ac8a45..1ccec0d 100644 Binary files a/migrations/tenant/versions/__pycache__/f6ecc306055a_adding_session_id_to_chatsession.cpython-312.pyc and b/migrations/tenant/versions/__pycache__/f6ecc306055a_adding_session_id_to_chatsession.cpython-312.pyc differ diff --git a/migrations/tenant/versions/__pycache__/f88854b2ac59_full_support_for_multiple_embedding_.cpython-312.pyc b/migrations/tenant/versions/__pycache__/f88854b2ac59_full_support_for_multiple_embedding_.cpython-312.pyc index c7d857f..770d81d 100644 Binary files a/migrations/tenant/versions/__pycache__/f88854b2ac59_full_support_for_multiple_embedding_.cpython-312.pyc and b/migrations/tenant/versions/__pycache__/f88854b2ac59_full_support_for_multiple_embedding_.cpython-312.pyc differ diff --git a/scripts/__pycache__/run_eveai_app.cpython-312.pyc b/scripts/__pycache__/run_eveai_app.cpython-312.pyc index 77f90cf..ba6168c 100644 Binary files a/scripts/__pycache__/run_eveai_app.cpython-312.pyc and b/scripts/__pycache__/run_eveai_app.cpython-312.pyc differ diff --git a/scripts/db_migrate.sh b/scripts/db_migrate.sh index 37ab0c1..61c312f 100755 --- a/scripts/db_migrate.sh +++ b/scripts/db_migrate.sh @@ -1,33 +1,41 @@ #!/usr/bin/env bash -# Usage: ./migrate.sh -m "Your migration message" -d migrations/public +# Usage: ./db_migrate.sh -m "Your migration message" -d migrations/public -cd "/Volumes/OWC4M2_1/Dropbox/Josako's Dev/Josako/EveAI/Development/eveAI/" || exit 1 -source "/Volumes/OWC4M2_1/Dropbox/Josako's Dev/Josako/EveAI/Development/eveAI/.venv/bin/activate" +# Load environment variables +set -a +source .env +set +a + +project_dir=$(pwd) +# Ensure you're in the correct directory +cd "$project_dir" || exit 1 + +# Load environment variables (including database connection details) +source .env + +# Set Flask app and Python path +export FLASK_APP=scripts/run_eveai_app.py +export PYTHONPATH="$PYTHONPATH:$project_dir" while getopts m:d: flag do case "${flag}" in m) message=${OPTARG};; d) directory=${OPTARG};; - *) # Catch-all for unexpected arguments - echo "Invalid option: -$OPTARG" >&2 - echo "Usage: ./migrate.sh -m \"Your migration message\" -d migrations/public" + *) + echo "Invalid option: ${flag}" exit 1 - ;; + ;; esac done # Check if the message and directory are provided if [ -z "$message" ] || [ -z "$directory" ]; then echo "Both message and directory are required." - echo "Usage: ./migrate.sh -m \"Your migration message\" -d migrations/public" + echo "Usage: ./db_migrate.sh -m \"Your migration message\" -d migrations/public" exit 1 fi -# Set FLASK_APP environment variable -export FLASK_APP=scripts/run_eveai_app.py # Modify if your Flask app is initiated differently -export PYTHONPATH="$PYTHONPATH:/Volumes/OWC4M2_1/Dropbox/Josako's Dev/Josako/EveAI/Development/eveAI/" - # Run the Flask migration command flask db migrate -m "$message" -d "$directory" \ No newline at end of file diff --git a/scripts/db_upgrade.sh b/scripts/db_upgrade.sh deleted file mode 100755 index 9291172..0000000 --- a/scripts/db_upgrade.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env bash - -# Usage: ./upgrade.sh -d migrations/public - -cd "/Volumes/OWC4M2_1/Dropbox/Josako's Dev/Josako/EveAI/Development/eveAI/" || exit 1 -source "/Volumes/OWC4M2_1/Dropbox/Josako's Dev/Josako/EveAI/Development/eveAI/.venv/bin/activate" - -while getopts d: flag -do - case "${flag}" in - d) directory=${OPTARG};; - *) # Catch-all for unexpected arguments - echo "Invalid option: -$OPTARG" >&2 - echo "Usage: ./upgrade.sh -d migrations/public" - exit 1 - ;; - esac -done - -# Check if the directory is provided -if [ -z "$directory" ]; then - echo "Directory parameter is required." - echo "Usage: ./upgrade.sh -d migrations/public" - exit 1 -fi - -# Set FLASK_APP environment variable -export FLASK_APP=scripts/run_eveai_app.py # Modify if your Flask app is initiated differently -export PYTHONPATH="$PYTHONPATH:/Volumes/OWC4M2_1/Dropbox/Josako's Dev/Josako/EveAI/Development/eveAI/" - -# Run the Flask upgrade command -flask db upgrade -d "$directory" \ No newline at end of file