iqasport / referee_hub

The hub for all internal data and management of that data in the IQA.
3 stars 4 forks source link

Database Migration instructions #376

Open manio143 opened 1 year ago

manio143 commented 1 year ago

To migrate the data from old PostgreSQL database to the new one use the pg_dump command. Under Windows it can be downloaded here: https://www.enterprisedb.com/download-postgresql-binaries Under Linux you can get it with PostgreSQL installation.

.\pg_dump -f backup.sql -C -c -d <db-name> -h <host-name> -p 5432 -U <user-name>

Next remove a few top and bottom lines from the backup file which pertain to users (we come with a preexisting user in the new db). Remove every line which assigns table ownership to a user.

Then run the backup file against the new database

.\psql -d <db-name> -h <host-name> -p 5432 -U <user-name> -f backup.sql

Finally execute the following to create the migrations table.

CREATE TABLE IF NOT EXISTS "__EFMigrationsHistory" (
    "MigrationId" character varying(150) NOT NULL,
    "ProductVersion" character varying(32) NOT NULL,
    CONSTRAINT "PK___EFMigrationsHistory" PRIMARY KEY ("MigrationId")
);

INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
VALUES ('20230419204938_InitialCreate', '7.0.4');
manio143 commented 1 year ago

For anything we deserialize as a URI - we need to ensure it's a valid URI (with http:// prefix and not an empty string).