60 lines
3.5 KiB
Bash
60 lines
3.5 KiB
Bash
file_publish="/docker-entrypoint-initdb.d/scripts/publish.psql"
|
||
files=(
|
||
##########################################################################
|
||
# schemas
|
||
"/docker-entrypoint-initdb.d/schemas/auth/auth.psql"
|
||
|
||
##########################################################################
|
||
# tables
|
||
# cabinet и user — раньше user_cabinet (на них ссылаются user_id / cabinet_id)
|
||
"/docker-entrypoint-initdb.d/schemas/auth/tables/cabinet.psql"
|
||
"/docker-entrypoint-initdb.d/schemas/auth/tables/user.psql"
|
||
"/docker-entrypoint-initdb.d/schemas/auth/tables/user_cabinet.psql"
|
||
|
||
##########################################################################
|
||
# functions
|
||
# cabinet
|
||
"/docker-entrypoint-initdb.d/schemas/auth/functions/cabinet/cabinet_insert.psql"
|
||
"/docker-entrypoint-initdb.d/schemas/auth/functions/cabinet/cabinet_update.psql"
|
||
"/docker-entrypoint-initdb.d/schemas/auth/functions/cabinet/cabinet_delete.psql"
|
||
"/docker-entrypoint-initdb.d/schemas/auth/functions/cabinet/cabinet_select.psql"
|
||
# user
|
||
"/docker-entrypoint-initdb.d/schemas/auth/functions/user/user_insert.psql"
|
||
"/docker-entrypoint-initdb.d/schemas/auth/functions/user/user_select.psql"
|
||
"/docker-entrypoint-initdb.d/schemas/auth/functions/user/user_select_by_ids.psql"
|
||
"/docker-entrypoint-initdb.d/schemas/auth/functions/user/user_get_by_login.psql"
|
||
# user_get_for_auth — единственная новая функция в схеме auth: поиск по login/email без сверки
|
||
# пароля (PBKDF2 сверяется в C#); сама таблица auth.user намеренно не изменена.
|
||
"/docker-entrypoint-initdb.d/schemas/auth/functions/user/user_get_for_auth.psql"
|
||
# user_get_profile — специализированное чтение профиля владельца токена (+ password_temp)
|
||
"/docker-entrypoint-initdb.d/schemas/auth/functions/user/user_get_profile.psql"
|
||
"/docker-entrypoint-initdb.d/schemas/auth/functions/user/user_delete.psql"
|
||
"/docker-entrypoint-initdb.d/schemas/auth/functions/user/user_set_is_blocked.psql"
|
||
"/docker-entrypoint-initdb.d/schemas/auth/functions/user/user_update.psql"
|
||
"/docker-entrypoint-initdb.d/schemas/auth/functions/user/user_update_password.psql"
|
||
"/docker-entrypoint-initdb.d/schemas/auth/functions/user/user_update_password_temp.psql"
|
||
"/docker-entrypoint-initdb.d/schemas/auth/functions/user/user_login_exists.psql"
|
||
"/docker-entrypoint-initdb.d/schemas/auth/functions/user/user_email_exists.psql"
|
||
# user_cabinet
|
||
"/docker-entrypoint-initdb.d/schemas/auth/functions/user_cabinet/user_cabinet_bulk_insert.psql"
|
||
"/docker-entrypoint-initdb.d/schemas/auth/functions/user_cabinet/user_cabinet_select.psql"
|
||
|
||
##########################################################################
|
||
# post-deploy (seed)
|
||
"/docker-entrypoint-initdb.d/schemas/auth/auth.post-deploy.psql"
|
||
|
||
)
|
||
|
||
> ${file_publish}
|
||
|
||
# ВАЖНО: явно устанавливаем UTF-8 перед вставкой seed-данных с кириллицей.
|
||
# Без этого psql может использовать системную кодировку клиента (LC_CTYPE),
|
||
# что приводит к двойному кодированию UTF-8 → Latin-1/CP1251 → UTF-8.
|
||
echo "SET client_encoding TO 'UTF8';" >> ${file_publish}
|
||
printf "\n\n" >> ${file_publish}
|
||
|
||
for item in "${files[@]}"; do
|
||
cat "${item}" >> "${file_publish}" && printf "\n\n\n" >> "${file_publish}"
|
||
done
|
||
# run publish.psql (база auth — POSTGRES_DB)
|
||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" -f "${file_publish}" |