2023-05-15 08:51:32 +08:00
|
|
|
from flask_sqlalchemy import SQLAlchemy
|
2024-08-01 11:16:49 +08:00
|
|
|
from sqlalchemy import MetaData
|
2023-05-15 08:51:32 +08:00
|
|
|
|
2024-08-01 11:16:49 +08:00
|
|
|
POSTGRES_INDEXES_NAMING_CONVENTION = {
|
|
|
|
'ix': '%(column_0_label)s_idx',
|
|
|
|
'uq': '%(table_name)s_%(column_0_name)s_key',
|
|
|
|
'ck': '%(table_name)s_%(constraint_name)s_check',
|
|
|
|
'fk': '%(table_name)s_%(column_0_name)s_fkey',
|
|
|
|
'pk': '%(table_name)s_pkey',
|
|
|
|
}
|
|
|
|
|
|
|
|
metadata = MetaData(naming_convention=POSTGRES_INDEXES_NAMING_CONVENTION)
|
|
|
|
db = SQLAlchemy(metadata=metadata)
|
2023-05-15 08:51:32 +08:00
|
|
|
|
|
|
|
|
|
|
|
def init_app(app):
|
|
|
|
db.init_app(app)
|