Skip to content

Commit

Permalink
Implement Flask-Migrate
Browse files Browse the repository at this point in the history
- Allows for some automation of the migration process
- Alembic folder was renamed to avoid colision with the alembic package.
  • Loading branch information
DMalone87 committed Feb 4, 2024
1 parent 0afa669 commit 2ae45d9
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 5 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions alembic/seeds.py → alembic_local/seeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
from backend.database.core import db

if app.env == "development":
import alembic.dev_seeds
import alembic_local.dev_seeds
elif app.env == "production":
import alembic.prod_seeds
import alembic_local.prod_seeds
File renamed without changes.
4 changes: 3 additions & 1 deletion backend/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from flask import Flask
from flask_mail import Mail
from flask_cors import CORS
from flask_migrate import Migrate
from backend.config import get_config_from_env
from backend.database import db
from backend.database import db_cli
Expand Down Expand Up @@ -40,6 +41,7 @@ def register_extensions(app: Flask):
user_manager.init_app(app)
jwt.init_app(app)
Mail(app)
Migrate(app, db)
CORS(app, resources={r"/api/*": {"origins": "*"}})


Expand All @@ -60,7 +62,7 @@ def register_commands(app: Flask):
@dev_only
def seed(ctx: click.Context):
"""Seed the database."""
from alembic.dev_seeds import create_seeds
from alembic_local.dev_seeds import create_seeds

create_seeds()

Expand Down
4 changes: 2 additions & 2 deletions frontend/helpers/api/mocks/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Incident, User } from ".."

export type TestUser = User & { password: string }

/** Matches alembic/dev_seeds.py */
/** Matches alembic_local/dev_seeds.py */
export const EXISTING_TEST_USER: TestUser = {
active: true,
emailConfirmedAt: null,
Expand All @@ -14,7 +14,7 @@ export const EXISTING_TEST_USER: TestUser = {
role: "Public"
}

/** Matches alembic/dev_seeds.py */
/** Matches alembic_local/dev_seeds.py */
export const EXISTING_TEST_INCIDENTS: Incident[] = (
[
[1, "10-01-2019Z", [-87.6974962, 41.6928005]],
Expand Down

0 comments on commit 2ae45d9

Please sign in to comment.