DD.WellWorkover.Cloud/AsbCloudDb
2024-07-29 11:55:43 +05:00
..
Migrations Поправлены названия некоторых секций (которые были без цифр) 2024-07-29 11:55:43 +05:00
Model Поправлены названия некоторых секций (которые были без цифр) 2024-07-29 11:55:43 +05:00
UsefulQueries fix encoding to utf8 (without bom), u200b, line endings, tabs to 3 spaces, variants of minus char to base minus char 2024-07-04 11:02:45 +05:00
AsbCloudDb.csproj Update nugets, fix nit issues, spelling 2024-07-08 11:09:43 +05:00
EFExtensions.cs Update nugets, fix nit issues, spelling 2024-07-08 11:09:43 +05:00
EFExtensionsExceptionHandling.cs fix encoding to utf8 (without bom), u200b, line endings, tabs to 3 spaces, variants of minus char to base minus char 2024-07-04 11:02:45 +05:00
EFExtensionsInitialization.cs fix encoding to utf8 (without bom), u200b, line endings, tabs to 3 spaces, variants of minus char to base minus char 2024-07-04 11:02:45 +05:00
EFExtensionsSortBy.cs fix encoding to utf8 (without bom), u200b, line endings, tabs to 3 spaces, variants of minus char to base minus char 2024-07-04 11:02:45 +05:00
install pg timescale.md fix encoding to utf8 (without bom), u200b, line endings, tabs to 3 spaces, variants of minus char to base minus char 2024-07-04 11:02:45 +05:00
Readme.md fix encoding to utf8 (without bom), u200b, line endings, tabs to 3 spaces, variants of minus char to base minus char 2024-07-04 11:02:45 +05:00
Setup db replication.md fix doc 2023-12-01 17:41:39 +05:00

Миграции

EF tools

https://docs.microsoft.com/ru-ru/ef/core/cli/dotnet

Установка:

dotnet tool install --global dotnet-ef

Обновление:

dotnet tool update --global dotnet-ef

Создать миграцию

dotnet ef migrations add <MigrationName> --project AsbCloudDb

Откатить миграцию

dotnet ef migrations remove --project AsbCloudDb

Удаляется последняя созданная миграция.

Применить миграции

При старте проекта применяются автоматически

 dotnet ef database update --project .\AsbCloudDb

Backup and restore

Backup

Terminal:

sudo -u postgres pg_dump -Fc -U postgres postgres -W > dump_2022-03-09.bak

Restore backup

Step 1. (Re)Create DB and schema IF needed.

psql:

--drop schema public cascade;
CREATE DATABASE postgres;
\c postgres
create schema public;

Step 2. Init timescaledb and prepare DB to restore

CREATE EXTENSION IF NOT EXISTS timescaledb;
SELECT timescaledb_pre_restore();

Step 3. Restore DB, then [Longest operation]

Terminal:

sudo -u postgres pg_restore -Fc -d postgres dump_2021-11-26.bak

OR psql:

\! pg_restore -Fc -d postgres dump_2021-11-26.bak

win: pg_restore -Fc -d postgres -U postgres -W dump_2022-01-11.bak Then 'exit restore mode' psql:

SELECT timescaledb_post_restore();