DD.WellWorkover.Cloud/AsbCloudDb
2021-12-07 11:34:06 +05:00
..
Migrations merge dev to this 2021-12-03 09:58:48 +05:00
Model merge dev to this 2021-12-03 09:58:48 +05:00
UsefulQueries BIG. Add timescaleDB into DB. 2021-11-13 18:47:11 +05:00
AsbCloudDb.csproj update EF 2021-09-23 15:26:55 +05:00
EFExtentions.cs refactor built query with less mem allocation. 2021-11-17 10:52:03 +05:00
install pg timescale.md BIG. Add timescaleDB into DB. 2021-11-13 18:47:11 +05:00
Readme.md Забрал домой 2021-12-07 11:34:06 +05:00

Миграции

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

dotnet ef migrations add <MigrationName> --project AsbCloudDb

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

dotnet ef migrations remvoe <MigrationName> --project AsbCloudDb

<MigrationName> - Name of migration class. После создания миграции обязательно прочитать сгенерированый код.

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

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

 dotnet ef database update --project .\AsbCloudDb

Backup and restore

Backup

Terminal:

sudo -u postgres pg_dump -Fc -U postgres postgres -W > dump_2021-11-26.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. Innit 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  psql -p 5499 -U postgres postgres -W < dump_2021-11-26.bak

OR psql:

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

Then 'exit resore mode' psql:

SELECT timescaledb_post_restore();