mirror of
https://github.com/dat515-2025/Group-8.git
synced 2026-03-22 15:12:08 +01:00
feat(infrastructure): database changes
This commit is contained in:
@@ -11,7 +11,7 @@ script_location = %(here)s/alembic
|
|||||||
# Uncomment the line below if you want the files to be prepended with date and time
|
# Uncomment the line below if you want the files to be prepended with date and time
|
||||||
# see https://alembic.sqlalchemy.org/en/latest/tutorial.html#editing-the-ini-file
|
# see https://alembic.sqlalchemy.org/en/latest/tutorial.html#editing-the-ini-file
|
||||||
# for all available tokens
|
# for all available tokens
|
||||||
# file_template = %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d%%(minute).2d-%%(rev)s_%%(slug)s
|
file_template = %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d%%(minute).2d-%%(rev)s_%%(slug)s
|
||||||
|
|
||||||
# sys.path path, will be prepended to sys.path if present.
|
# sys.path path, will be prepended to sys.path if present.
|
||||||
# defaults to the current working directory. for multiple paths, the path separator
|
# defaults to the current working directory. for multiple paths, the path separator
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
"""Init migration
|
"""add categories
|
||||||
|
|
||||||
Revision ID: 81f275275556
|
Revision ID: 63e072f09836
|
||||||
Revises:
|
Revises:
|
||||||
Create Date: 2025-09-24 17:39:25.346690
|
Create Date: 2025-10-09 14:56:14.653249
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from typing import Sequence, Union
|
from typing import Sequence, Union
|
||||||
@@ -13,7 +13,7 @@ import sqlalchemy as sa
|
|||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision: str = '81f275275556'
|
revision: str = '63e072f09836'
|
||||||
down_revision: Union[str, Sequence[str], None] = None
|
down_revision: Union[str, Sequence[str], None] = None
|
||||||
branch_labels: Union[str, Sequence[str], None] = None
|
branch_labels: Union[str, Sequence[str], None] = None
|
||||||
depends_on: Union[str, Sequence[str], None] = None
|
depends_on: Union[str, Sequence[str], None] = None
|
||||||
@@ -22,12 +22,6 @@ depends_on: Union[str, Sequence[str], None] = None
|
|||||||
def upgrade() -> None:
|
def upgrade() -> None:
|
||||||
"""Upgrade schema."""
|
"""Upgrade schema."""
|
||||||
# ### commands auto generated by Alembic - please adjust! ###
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
op.create_table('transaction',
|
|
||||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
|
||||||
sa.Column('amount', sa.Float(), nullable=False),
|
|
||||||
sa.Column('description', sa.String(length=255), nullable=True),
|
|
||||||
sa.PrimaryKeyConstraint('id')
|
|
||||||
)
|
|
||||||
op.create_table('user',
|
op.create_table('user',
|
||||||
sa.Column('first_name', sa.String(length=100), nullable=True),
|
sa.Column('first_name', sa.String(length=100), nullable=True),
|
||||||
sa.Column('last_name', sa.String(length=100), nullable=True),
|
sa.Column('last_name', sa.String(length=100), nullable=True),
|
||||||
@@ -40,13 +34,38 @@ def upgrade() -> None:
|
|||||||
sa.PrimaryKeyConstraint('id')
|
sa.PrimaryKeyConstraint('id')
|
||||||
)
|
)
|
||||||
op.create_index(op.f('ix_user_email'), 'user', ['email'], unique=True)
|
op.create_index(op.f('ix_user_email'), 'user', ['email'], unique=True)
|
||||||
|
op.create_table('categories',
|
||||||
|
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
||||||
|
sa.Column('name', sa.String(length=100), nullable=False),
|
||||||
|
sa.Column('description', sa.String(length=255), nullable=True),
|
||||||
|
sa.Column('user_id', fastapi_users_db_sqlalchemy.generics.GUID(), nullable=False),
|
||||||
|
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
|
||||||
|
sa.PrimaryKeyConstraint('id'),
|
||||||
|
sa.UniqueConstraint('name')
|
||||||
|
)
|
||||||
|
op.create_table('transaction',
|
||||||
|
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
||||||
|
sa.Column('amount', sa.Float(), nullable=False),
|
||||||
|
sa.Column('description', sa.String(length=255), nullable=True),
|
||||||
|
sa.Column('user_id', fastapi_users_db_sqlalchemy.generics.GUID(), nullable=False),
|
||||||
|
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
|
||||||
|
sa.PrimaryKeyConstraint('id')
|
||||||
|
)
|
||||||
|
op.create_table('category_transaction',
|
||||||
|
sa.Column('id_category', sa.Integer(), nullable=True),
|
||||||
|
sa.Column('id_transaction', sa.Integer(), nullable=True),
|
||||||
|
sa.ForeignKeyConstraint(['id_category'], ['categories.id'], ),
|
||||||
|
sa.ForeignKeyConstraint(['id_transaction'], ['transaction.id'], )
|
||||||
|
)
|
||||||
# ### end Alembic commands ###
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
def downgrade() -> None:
|
def downgrade() -> None:
|
||||||
"""Downgrade schema."""
|
"""Downgrade schema."""
|
||||||
# ### commands auto generated by Alembic - please adjust! ###
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.drop_table('category_transaction')
|
||||||
|
op.drop_table('transaction')
|
||||||
|
op.drop_table('categories')
|
||||||
op.drop_index(op.f('ix_user_email'), table_name='user')
|
op.drop_index(op.f('ix_user_email'), table_name='user')
|
||||||
op.drop_table('user')
|
op.drop_table('user')
|
||||||
op.drop_table('transaction')
|
|
||||||
# ### end Alembic commands ###
|
# ### end Alembic commands ###
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
"""add categories
|
|
||||||
|
|
||||||
Revision ID: a60134ef6c4c
|
|
||||||
Revises: c5e9d6c59812
|
|
||||||
Create Date: 2025-10-09 14:29:31.170347
|
|
||||||
|
|
||||||
"""
|
|
||||||
from typing import Sequence, Union
|
|
||||||
|
|
||||||
import fastapi_users_db_sqlalchemy
|
|
||||||
from alembic import op
|
|
||||||
import sqlalchemy as sa
|
|
||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
|
||||||
revision: str = 'a60134ef6c4c'
|
|
||||||
down_revision: Union[str, Sequence[str], None] = 'c5e9d6c59812'
|
|
||||||
branch_labels: Union[str, Sequence[str], None] = None
|
|
||||||
depends_on: Union[str, Sequence[str], None] = None
|
|
||||||
|
|
||||||
|
|
||||||
def upgrade() -> None:
|
|
||||||
"""Upgrade schema."""
|
|
||||||
# ### commands auto generated by Alembic - please adjust! ###
|
|
||||||
op.create_table('categories',
|
|
||||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
|
||||||
sa.Column('name', sa.String(length=100), nullable=False),
|
|
||||||
sa.Column('description', sa.String(length=255), nullable=True),
|
|
||||||
sa.Column('user_id', fastapi_users_db_sqlalchemy.generics.GUID(), nullable=False),
|
|
||||||
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
|
|
||||||
sa.PrimaryKeyConstraint('id'),
|
|
||||||
sa.UniqueConstraint('name')
|
|
||||||
)
|
|
||||||
op.create_table('category_transaction',
|
|
||||||
sa.Column('id_category', sa.Integer(), nullable=True),
|
|
||||||
sa.Column('id_transaction', sa.Integer(), nullable=True),
|
|
||||||
sa.ForeignKeyConstraint(['id_category'], ['categories.id'], ),
|
|
||||||
sa.ForeignKeyConstraint(['id_transaction'], ['transaction.id'], )
|
|
||||||
)
|
|
||||||
# ### end Alembic commands ###
|
|
||||||
|
|
||||||
|
|
||||||
def downgrade() -> None:
|
|
||||||
"""Downgrade schema."""
|
|
||||||
# ### commands auto generated by Alembic - please adjust! ###
|
|
||||||
op.drop_table('category_transaction')
|
|
||||||
op.drop_table('categories')
|
|
||||||
# ### end Alembic commands ###
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
"""User transaction relationship
|
|
||||||
|
|
||||||
Revision ID: c5e9d6c59812
|
|
||||||
Revises: 81f275275556
|
|
||||||
Create Date: 2025-10-09 14:17:19.983889
|
|
||||||
|
|
||||||
"""
|
|
||||||
from typing import Sequence, Union
|
|
||||||
|
|
||||||
import fastapi_users_db_sqlalchemy
|
|
||||||
from alembic import op
|
|
||||||
import sqlalchemy as sa
|
|
||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
|
||||||
revision: str = 'c5e9d6c59812'
|
|
||||||
down_revision: Union[str, Sequence[str], None] = '81f275275556'
|
|
||||||
branch_labels: Union[str, Sequence[str], None] = None
|
|
||||||
depends_on: Union[str, Sequence[str], None] = None
|
|
||||||
|
|
||||||
|
|
||||||
def upgrade() -> None:
|
|
||||||
"""Upgrade schema."""
|
|
||||||
# ### commands auto generated by Alembic - please adjust! ###
|
|
||||||
op.alter_column('transaction', 'user_id',
|
|
||||||
existing_type=sa.UUID(),
|
|
||||||
type_=fastapi_users_db_sqlalchemy.generics.GUID(),
|
|
||||||
existing_nullable=False)
|
|
||||||
op.create_foreign_key(None, 'transaction', 'user', ['user_id'], ['id'])
|
|
||||||
# ### end Alembic commands ###
|
|
||||||
|
|
||||||
|
|
||||||
def downgrade() -> None:
|
|
||||||
"""Downgrade schema."""
|
|
||||||
# ### commands auto generated by Alembic - please adjust! ###
|
|
||||||
op.drop_constraint(None, 'transaction', type_='foreignkey')
|
|
||||||
op.alter_column('transaction', 'user_id',
|
|
||||||
existing_type=fastapi_users_db_sqlalchemy.generics.GUID(),
|
|
||||||
type_=sa.UUID(),
|
|
||||||
existing_nullable=False)
|
|
||||||
# ### end Alembic commands ###
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
apiVersion: v2
|
apiVersion: v2
|
||||||
name: maxscale-helm
|
name: maxscale-helm
|
||||||
version: 1.0.7
|
version: 1.0.8
|
||||||
description: Helm chart for MaxScale related Kubernetes manifests
|
description: Helm chart for MaxScale related Kubernetes manifests
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ spec:
|
|||||||
- name: DATABASE_ENABLE_SSL
|
- name: DATABASE_ENABLE_SSL
|
||||||
value: "yes"
|
value: "yes"
|
||||||
- name: DATABASE_HOST
|
- name: DATABASE_HOST
|
||||||
value: "mariadb-repl"
|
value: "mariadb-repl-maxscale-internal"
|
||||||
- name: DATABASE_PORT_NUMBER
|
- name: DATABASE_PORT_NUMBER
|
||||||
value: "3306"
|
value: "3306"
|
||||||
- name: PHPMYADMIN_ALLOW_NO_PASSWORD
|
- name: PHPMYADMIN_ALLOW_NO_PASSWORD
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ resource "helm_release" "mariadb-operator" {
|
|||||||
resource "helm_release" "maxscale_helm" {
|
resource "helm_release" "maxscale_helm" {
|
||||||
name = "maxscale-helm"
|
name = "maxscale-helm"
|
||||||
chart = "${path.module}/charts/maxscale-helm"
|
chart = "${path.module}/charts/maxscale-helm"
|
||||||
version = "1.0.7"
|
version = "1.0.8"
|
||||||
depends_on = [ helm_release.mariadb-operator-crds, kubectl_manifest.secrets ]
|
depends_on = [ helm_release.mariadb-operator-crds, kubectl_manifest.secrets ]
|
||||||
timeout = 3600
|
timeout = 3600
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user