DD.WellWorkover.Cloud/AsbCloudDb
2021-12-03 17:34:24 +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 Doc timascale backup and restore. 2021-12-03 17:34:24 +05:00

Миграции

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

dotnet ef migrations add <MigrationName> --project AsbCloudDb

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

dotnet ef migrations remvoe <MigrationName> --project AsbCloudDb

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

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

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

 dotnet ef database update --project .\AsbCloudDb

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 needeed.

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 'exit resore mode'. [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 psql:

SELECT timescaledb_post_restore();