Skip to content

Commit 36c145a

Browse files
committed
🚑 Migrate from pg 12 to mysql 8.
1. Migrate from pg 12 to mysql 8. 2. uv update to 0.5.3 3. user.id item.id type changed, from uuid to str. (uuid format str) 4. disable alembic
1 parent e345273 commit 36c145a

23 files changed

+111
-422
lines changed

.env

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,16 @@ SMTP_TLS=True
3131
SMTP_SSL=False
3232
SMTP_PORT=587
3333

34-
# Postgres
35-
POSTGRES_SERVER=localhost
36-
POSTGRES_PORT=5432
37-
POSTGRES_DB=app
38-
POSTGRES_USER=postgres
39-
POSTGRES_PASSWORD=changethis
34+
# MySQL
35+
MYSQL_SERVER=localhost
36+
MYSQL_PORT=3306
37+
MYSQL_ROOT_PASSWORD=changethis
38+
MYSQL_DATABASE=app
39+
MYSQL_USER=mysql
40+
MYSQL_PASSWORD=changethis
4041

4142
SENTRY_DSN=
4243

4344
# Configure these with your own Docker registry images
44-
DOCKER_IMAGE_BACKEND=backend
45-
DOCKER_IMAGE_FRONTEND=frontend
45+
DOCKER_IMAGE_BACKEND=caseycui/backend
46+
DOCKER_IMAGE_FRONTEND=caseycui/frontend

.github/workflows/deploy-production.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
SMTP_USER: ${{ secrets.SMTP_USER }}
2424
SMTP_PASSWORD: ${{ secrets.SMTP_PASSWORD }}
2525
EMAILS_FROM_EMAIL: ${{ secrets.EMAILS_FROM_EMAIL }}
26-
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
26+
MYSQL_PASSWORD: ${{ secrets.MYSQL_PASSWORD }}
2727
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
2828
steps:
2929
- name: Checkout

.github/workflows/deploy-staging.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
SMTP_USER: ${{ secrets.SMTP_USER }}
2424
SMTP_PASSWORD: ${{ secrets.SMTP_PASSWORD }}
2525
EMAILS_FROM_EMAIL: ${{ secrets.EMAILS_FROM_EMAIL }}
26-
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
26+
MYSQL_PASSWORD: ${{ secrets.MYSQL_PASSWORD }}
2727
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
2828
steps:
2929
- name: Checkout

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
-[**FastAPI**](https://fastapi.tiangolo.com) for the Python backend API.
99
- 🧰 [SQLModel](https://sqlmodel.tiangolo.com) for the Python SQL database interactions (ORM).
1010
- 🔍 [Pydantic](https://docs.pydantic.dev), used by FastAPI, for the data validation and settings management.
11-
- 💾 [PostgreSQL](https://www.postgresql.org) as the SQL database.
11+
- 💾 [MySQL](https://www.mysql.org) as the SQL database.
1212
- 🚀 [React](https://react.dev) for the frontend.
1313
- 💃 Using TypeScript, hooks, Vite, and other parts of a modern frontend stack.
1414
- 🎨 [Chakra UI](https://chakra-ui.com) for the frontend components.
@@ -134,7 +134,8 @@ Before deploying it, make sure you change at least the values for:
134134

135135
- `SECRET_KEY`
136136
- `FIRST_SUPERUSER_PASSWORD`
137-
- `POSTGRES_PASSWORD`
137+
- `MYSQL_ROOT_PASSWORD`
138+
- `MYSQL_PASSWORD`
138139

139140
You can (and should) pass these as environment variables from secrets.
140141

@@ -209,7 +210,7 @@ The input variables, with their default values (some auto generated) are:
209210
- `smtp_user`: (default: "") The SMTP server user to send emails, you can set it later in .env.
210211
- `smtp_password`: (default: "") The SMTP server password to send emails, you can set it later in .env.
211212
- `emails_from_email`: (default: `"[email protected]"`) The email account to send emails from, you can set it later in .env.
212-
- `postgres_password`: (default: `"changethis"`) The password for the PostgreSQL database, stored in .env, you can generate one with the method above.
213+
- `mysql_password`: (default: `"changethis"`) The password for the MySQL database, stored in .env, you can generate one with the method above.
213214
- `sentry_dsn`: (default: "") The DSN for Sentry, if you are using it, you can set it later in .env.
214215

215216
## Backend Development

backend/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ WORKDIR /app/
66

77
# Install uv
88
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#installing-uv
9-
COPY --from=ghcr.io/astral-sh/uv:0.4.15 /uv /bin/uv
9+
COPY --from=ghcr.io/astral-sh/uv:0.5.3 /uv /bin/uv
1010

1111
# Place executables in the environment at the front of the path
1212
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#using-the-environment

backend/app/alembic/versions/1a31ce608336_add_cascade_delete_relationships.py

Lines changed: 0 additions & 37 deletions
This file was deleted.

backend/app/alembic/versions/9c0a54914c78_add_max_length_for_string_varchar_.py

Lines changed: 0 additions & 69 deletions
This file was deleted.

backend/app/alembic/versions/d98dd8ec85a3_edit_replace_id_integers_in_all_models_.py

Lines changed: 0 additions & 90 deletions
This file was deleted.

backend/app/alembic/versions/e2412789c190_initialize_models.py

Lines changed: 0 additions & 54 deletions
This file was deleted.

backend/app/api/routes/items.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import uuid
21
from typing import Any
32

43
from fastapi import APIRouter, HTTPException
@@ -42,7 +41,7 @@ def read_items(
4241

4342

4443
@router.get("/{id}", response_model=ItemPublic)
45-
def read_item(session: SessionDep, current_user: CurrentUser, id: uuid.UUID) -> Any:
44+
def read_item(session: SessionDep, current_user: CurrentUser, id: str) -> Any:
4645
"""
4746
Get item by ID.
4847
"""
@@ -73,7 +72,7 @@ def update_item(
7372
*,
7473
session: SessionDep,
7574
current_user: CurrentUser,
76-
id: uuid.UUID,
75+
id: str,
7776
item_in: ItemUpdate,
7877
) -> Any:
7978
"""
@@ -93,9 +92,7 @@ def update_item(
9392

9493

9594
@router.delete("/{id}")
96-
def delete_item(
97-
session: SessionDep, current_user: CurrentUser, id: uuid.UUID
98-
) -> Message:
95+
def delete_item(session: SessionDep, current_user: CurrentUser, id: str) -> Message:
9996
"""
10097
Delete an item.
10198
"""

0 commit comments

Comments
 (0)