Add postgresql database support (#475)

* feat: add postgresql db supports

* change: change mysql conn str create way

* fix: Modify the default alembic migration file to meet multi-database support

* Update settings and lint

* update models

* Simplify database config

* Simplify the get db method

* Update create db url

* Updated model type adaptation

* Update sql scripts

* Fix models type

* Adaptation to postgresql code generation

* Update README.md

* Fix alembic file template

* Update docker scripts
This commit is contained in:
Meepoljdx
2024-12-25 22:04:04 +08:00
committed by GitHub
parent 4f59f459a0
commit 78dad3021a
81 changed files with 1643 additions and 748 deletions
@@ -1,3 +1,4 @@
# Docker
DOCKER_MYSQL_MAP_PORT=13306
DOCKER_POSTGRES_MAP_PORT=15432
DOCKER_REDIS_MAP_PORT=16379
+6 -5
View File
@@ -1,10 +1,11 @@
# Env: dev、pro
ENVIRONMENT='dev'
# MySQL
MYSQL_HOST='fba_mysql'
MYSQL_PORT=3306
MYSQL_USER='root'
MYSQL_PASSWORD='123456'
# Database
DATABASE_TYPE='mysql'
DATABASE_HOST='fba_mysql'
DATABASE_PORT=3306
DATABASE_USER='root'
DATABASE_PASSWORD='123456'
# Redis
REDIS_HOST='fba_redis'
REDIS_PORT=6379
@@ -1,5 +1,3 @@
version: "3.10"
networks:
fba_network:
name: fba_network
@@ -42,7 +40,7 @@ services:
wait-for-it -s fba_mysql:3306 -s fba_redis:6379 -t 300
mkdir -p /var/log/supervisor/
supervisord -c /fba/deploy/backend/supervisor.conf
supervisorctl restart fastapi_server
supervisorctl restart
fba_mysql:
image: mysql:8.0.29
@@ -64,6 +62,21 @@ services:
--collation-server=utf8mb4_general_ci
--lower_case_table_names=1
# fba_postgres:
# image: postgres:16
# ports:
# - "${DOCKER_POSTGRES_MAP_PORT:-5432}:5432"
# container_name: fba_postgres
# restart: always
# environment:
# POSTGRES_DB: fba
# POSTGRES_PASSWORD: 123456
# TZ: Asia/Shanghai
# volumes:
# - fba_postgres:/var/lib/postgresql/data
# networks:
# - fba_network
fba_redis:
image: redis:6.2.7
ports:
@@ -77,8 +90,6 @@ services:
networks:
- fba_network
# The backend is dedicated, which conflicts with fba_uiIf you choose to use fba_ui
# you should stop using fba_nginx container and use fba_ui container
fba_nginx:
image: nginx
ports:
@@ -93,10 +104,6 @@ services:
networks:
- fba_network
# # If the server memory is less than 4GB and CPU less than four cores
# # it is recommended to build this container separately: docker-compose build fba_ui
# # You can also go to fba_ui project and build it individuallyhowever,
# # that make sure to create the docker network before the build: docker network create fba_network
# fba_ui:
# build:
# context: /root/fastapi_best_architecture_ui
@@ -114,9 +121,6 @@ services:
# - -g
# - daemon off;
# volumes:
# # nginx https conf
# # When deploying through docker, you need to open this configuration item and
# # ensure that the docker_ssl path is consistent with that in nginx conf
# # - local_ssl_pem_path:/etc/ssl/xxx.pem
# # - local_ssl_key_path:/etc/ssl/xxx.key
# - fba_static:/www/fba_server/backend/static
@@ -159,6 +163,4 @@ services:
wait-for-it -s fba_rabbitmq:5672 -t 300
mkdir -p /var/log/supervisor/
supervisord -c /fba/deploy/backend/supervisor.conf
supervisorctl restart celery_worker
supervisorctl restart celery_beat
supervisorctl restart celery_flower
supervisorctl restart