Skip to content

Commit

Permalink
Merge branch 'release-0.2.0' into LCFS-1255-AddOrganizationNameFSE
Browse files Browse the repository at this point in the history
  • Loading branch information
areyeslo authored Dec 9, 2024
2 parents e05ed7e + 8e4aa91 commit bf87c6e
Show file tree
Hide file tree
Showing 126 changed files with 3,132 additions and 1,266 deletions.
8 changes: 4 additions & 4 deletions backend/Dockerfile.openshift
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ ENV POETRY_CACHE_DIR=/.cache/pypoetry
RUN poetry install --only main

# Removing gcc
# RUN apt-get purge -y \
# gcc \
# && rm -rf /var/lib/apt/lists/*
RUN apt-get purge -y \
gcc \
&& rm -rf /var/lib/apt/lists/*

# Copying the actual application, wait-for-it script, and prestart script
COPY . /app/
Expand All @@ -45,4 +45,4 @@ RUN chmod +x /app/wait-for-it.sh /app/lcfs/prestart.sh /app/lcfs/start.sh
# Set the APP_ENVIRONMENT variable to 'production'
ENV APP_ENVIRONMENT=prod

CMD ["/app/lcfs/start.sh"]
CMD ["/app/lcfs/start.sh"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""Add notifications email to user_profile
Revision ID: b69a33bbd135
Revises: 8491890dd688
Create Date: 2024-12-05 20:48:24.724112
"""

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "b69a33bbd135"
down_revision = "8491890dd688"
branch_labels = None
depends_on = None


def upgrade() -> None:
# Add notifications_email column to user_profile table
op.add_column(
"user_profile",
sa.Column(
"notifications_email",
sa.String(length=255),
nullable=True,
comment="Email address used for notifications",
),
)


def downgrade() -> None:
# Remove notifications_email column from user_profile table
op.drop_column("user_profile", "notifications_email")
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
"""Update Notification Types and remove data
Revision ID: d4104af84f2b
Revises: b69a33bbd135
Create Date: 2024-12-05 02:20:33.898150
"""

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects.postgresql import ENUM

# Revision identifiers, used by Alembic.
revision = "d4104af84f2b"
down_revision = "b69a33bbd135"
branch_labels = None
depends_on = None


def upgrade():
# Remove the notification types added in the previous migration
op.execute("DELETE FROM notification_type;")

# Alter the `name` column in `notification_type` to be a VARCHAR
with op.batch_alter_table("notification_type") as batch_op:
batch_op.alter_column(
"name",
existing_type=ENUM(
"TRANSFER_PARTNER_UPDATE",
"TRANSFER_DIRECTOR_REVIEW",
"INITIATIVE_APPROVED",
"INITIATIVE_DA_REQUEST",
"SUPPLEMENTAL_REQUESTED",
"DIRECTOR_ASSESSMENT",
name="notification_type_enum_v2",
),
type_=sa.String(length=255),
existing_nullable=False,
)

# Drop the old enum types
op.execute("DROP TYPE IF EXISTS notification_type_enum_v2;")


def downgrade():
# First, remove all existing data that might not match the enum
op.execute("DELETE FROM notification_type;")

# Re-create the old enum type
notification_type_enum_v2 = ENUM(
"TRANSFER_PARTNER_UPDATE",
"TRANSFER_DIRECTOR_REVIEW",
"INITIATIVE_APPROVED",
"INITIATIVE_DA_REQUEST",
"SUPPLEMENTAL_REQUESTED",
"DIRECTOR_ASSESSMENT",
name="notification_type_enum_v2",
)
notification_type_enum_v2.create(op.get_bind(), checkfirst=False)

# Alter the `name` column back to the old enum
with op.batch_alter_table("notification_type") as batch_op:
batch_op.alter_column(
"name",
type_=notification_type_enum_v2,
existing_type=sa.String(length=255),
postgresql_using="name::notification_type_enum_v2",
existing_nullable=False,
)

# Re-insert the previous notification types
op.execute(
"""
INSERT INTO notification_type (notification_type_id, name, description, email_content, create_user, update_user)
VALUES
(1, 'TRANSFER_PARTNER_UPDATE', 'Transfer partner update notification', 'Email content for transfer partner update', 'system', 'system'),
(2, 'TRANSFER_DIRECTOR_REVIEW', 'Director review notification', 'Email content for director review', 'system', 'system'),
(3, 'INITIATIVE_APPROVED', 'Initiative approved notification', 'Email content for initiative approval', 'system', 'system'),
(4, 'INITIATIVE_DA_REQUEST', 'DA request notification', 'Email content for DA request', 'system', 'system'),
(5, 'SUPPLEMENTAL_REQUESTED', 'Supplemental requested notification', 'Email content for supplemental request', 'system', 'system'),
(6, 'DIRECTOR_ASSESSMENT', 'Director assessment notification', 'Email content for director assessment', 'system', 'system');
"""
)

# Reset the sequence for the id column with correct sequence name
op.execute(
"""
SELECT setval('notification_type_notification_type_id_seq', (SELECT MAX(notification_type_id) FROM notification_type));
"""
)
Loading

0 comments on commit bf87c6e

Please sign in to comment.