This repository has been archived by the owner on Jun 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from logion-network/feature/migrate-to-back
Migration to backend procedure.
- Loading branch information
Showing
9 changed files
with
149 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,6 @@ | ||
# logion-directory | ||
Logion legal officers directory | ||
|
||
## Initial setup | ||
|
||
1. Start a database: | ||
|
||
`docker run --name logion-postgres-directory -e POSTGRES_PASSWORD=secret -p 5432:5432 postgres:12` | ||
|
||
(or `docker start -a logion-postgres-directory` for a subsequent start). | ||
|
||
2. Create a config file `ormconfig.json` based on [`ormconfig.json.sample`](ormconfig.json.sample). | ||
|
||
3. Create the schema: `yarn typeorm migration:run` | ||
4. Populate the DB with legal officers (using well-known polkadot account) : [`legal_officers.sql`](test/integration/model/legal_officers.sql) | ||
5. Start the server: `yarn start` | ||
|
||
## Change DB schema | ||
|
||
1. Adapt the model with the proper annotations. | ||
2. Choose a name for the migration, for instance `MyMigration` | ||
3. Run `yarn typeorm migration:generate -n MyMigration` - this will generate a new migration `TIMESTAMP-MyMigration.ts` under [migration](/src/logion/migration). | ||
4. (Optional) Fix the generated file. | ||
5. Apply the migration(s): `yarn typeorm migration:run` | ||
6. (Optional) Revert the last migration: `yarn typeorm migration:revert` | ||
⚠️ The directory is about to be retired. | ||
The details of the legal officers are moved to their respective backend's. | ||
See [technical procedure](./migrate-to-backend/procedure.md) for more details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
DELETE FROM legal_officer WHERE (1=1 | ||
AND address <> '5GYirZEq8byGJePM9FM3JQG8Zwc5B6AcNpqgbrFvGRw2VQKE' -- Sylvian | ||
AND address <> '5Hox4L7Ek1CrXwbYzH8v64WvXkp6rQRkgxuhqE3i2c3farQ9' -- Rui | ||
); | ||
SELECT address, first_name | ||
FROM legal_officer ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
DELETE FROM legal_officer WHERE (1=1 | ||
AND address <> '5FQvrVyaxF6bmQkSKb6Xr9LdiWG4sr3CoyqPQvxJusowisoj' -- Patrick | ||
AND address <> '5CZy9rGJBsSF9tQ6SkWsjA7kTBiN5ZYJm9zs5ByVPDHCkNHJ' -- François-Michel | ||
AND address <> '5FmqTpGanDBVHedXf42fiuWD8d2iBa2Ve8EfG13juifnpgat' -- Eline | ||
); | ||
SELECT address, first_name | ||
FROM legal_officer ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
DELETE FROM legal_officer WHERE (1=1 | ||
AND address <> '5HGLG8z2jm5KnHeWh2Du8tLLkEVmJ2B6sEnqVsxC2FYjxWRP' -- Romain | ||
AND address <> '5Gn9QQ6Nnut9qv3yPH2N8ZheaYGaEDQZAiRrdiDq3sBBFPQ2' -- Alain | ||
); | ||
SELECT address, first_name | ||
FROM legal_officer ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
-- | ||
-- PostgreSQL database dump | ||
-- | ||
|
||
-- Dumped from database version 12.9 (Debian 12.9-1.pgdg110+1) | ||
-- Dumped by pg_dump version 12.9 (Debian 12.9-1.pgdg110+1) | ||
|
||
SET statement_timeout = 0; | ||
SET lock_timeout = 0; | ||
SET idle_in_transaction_session_timeout = 0; | ||
SET client_encoding = 'UTF8'; | ||
SET standard_conforming_strings = on; | ||
SELECT pg_catalog.set_config('search_path', '', false); | ||
SET check_function_bodies = false; | ||
SET xmloption = content; | ||
SET client_min_messages = warning; | ||
SET row_security = off; | ||
|
||
-- | ||
-- Data for Name: legal_officer; Type: TABLE DATA; Schema: public; Owner: postgres | ||
-- | ||
|
||
INSERT INTO public.legal_officer (address, first_name, last_name, email, phone_number, company, line1, line2, postal_code, city, country, additional_details) VALUES ('5FmqTpGanDBVHedXf42fiuWD8d2iBa2Ve8EfG13juifnpgat', 'Eline', 'Duysens', 'e.duysens@chartierpartners.be', '+32 82 22 50 50', 'CHARTIER & PARTNERS', 'Rue du Calvaire, 1', '', '5620', 'FLORENNES', 'Belgique', 'CHARTIER & PARTNERS\nSiège administratif :\nzoning de la voie cuivrée, 34\n5503 Sorinnes (Dinant)\nBelgique\nEmail: info@chartierpartners.be'); | ||
INSERT INTO public.legal_officer (address, first_name, last_name, email, phone_number, company, line1, line2, postal_code, city, country, additional_details) VALUES ('5GYirZEq8byGJePM9FM3JQG8Zwc5B6AcNpqgbrFvGRw2VQKE', 'Sylvian', 'Dorol', 's.dorol@venezia-huissiers.com', '+ 33 1 46 24 15 21', 'Venezia & Associés', '130 avenue Charles de Gaulle', '', '92200', 'Neuilly sur seine', 'France', NULL); | ||
INSERT INTO public.legal_officer (address, first_name, last_name, email, phone_number, company, line1, line2, postal_code, city, country, additional_details) VALUES ('5FQvrVyaxF6bmQkSKb6Xr9LdiWG4sr3CoyqPQvxJusowisoj', 'Patrick', 'Gielen', 'pg@modero.be', '+32 498 237 107', 'MODERO', 'Huissier de Justice', 'Rue Beckers 17', '1040', 'Etterbeek', 'Belgique', NULL); | ||
INSERT INTO public.legal_officer (address, first_name, last_name, email, phone_number, company, line1, line2, postal_code, city, country, additional_details) VALUES ('5EnvH6Lq6LCNZdwS6xbpndEh1YWB51rsDD2pwGJvt13Ta68B', 'Carlos', 'CALVO', 'carlos.calvo@huissier-luxembourg.com', '+35244133340', 'Etude Carlos Calvo', '65, rue d''Eich', '', '1461', 'LUXEMBOURG', 'Luxembourg', '- statements of facts | ||
- auctions | ||
- service of documents | ||
- debt recovery '); | ||
INSERT INTO public.legal_officer (address, first_name, last_name, email, phone_number, company, line1, line2, postal_code, city, country, additional_details) VALUES ('5Hox4L7Ek1CrXwbYzH8v64WvXkp6rQRkgxuhqE3i2c3farQ9', 'Rui', 'Simão', 'simao@msalaw.pt', '+31210996222', 'Morais, Simão & Associados - Solicitadores e Agentes de Execução, SP RL', 'Av. James Gilman, 50 A', '', '2685-068', 'Sacavém', 'Portugal', ''); | ||
INSERT INTO public.legal_officer (address, first_name, last_name, email, phone_number, company, line1, line2, postal_code, city, country, additional_details) VALUES ('5CZy9rGJBsSF9tQ6SkWsjA7kTBiN5ZYJm9zs5ByVPDHCkNHJ', 'François-Michel', 'Huwart', 'fmh@modero.be', '+32495854111', 'Modero Hainaut', 'Avenue des Bassins 44', '', '7000', 'Mons', 'Belgium', ''); | ||
INSERT INTO public.legal_officer (address, first_name, last_name, email, phone_number, company, line1, line2, postal_code, city, country, additional_details) VALUES ('5Gn9QQ6Nnut9qv3yPH2N8ZheaYGaEDQZAiRrdiDq3sBBFPQ2', 'Alain', 'Barland', 'alain.barland@auxilia-conseils.com', '+33 (0)6 98 39 18 03', 'Me Alain Barland - Auxilia Conseils 18', 'Commissaire de Justice - Coordinateur de Justice', '7 rue Jean-François Champollion - Parc Comitec', '18000', 'BOURGES', 'France', ''); | ||
INSERT INTO public.legal_officer (address, first_name, last_name, email, phone_number, company, line1, line2, postal_code, city, country, additional_details) VALUES ('5HGLG8z2jm5KnHeWh2Du8tLLkEVmJ2B6sEnqVsxC2FYjxWRP', 'Romain', 'GIRONDEL', 'r.girondel@huissier-42.com', '+33477323527', 'S.E.L.A.R.L. MSM HUISSIERS & ASSOCIES ST ETIENNE, C. SALICHON - A. MATHIEU - R. GIRONDEL', 'Commissaires de justice associés', '10 rue Jacques Desgeorges', '42000', 'SAINT-ETIENNE', 'FRANCE', ''); | ||
|
||
|
||
-- | ||
-- PostgreSQL database dump complete | ||
-- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Directory migration procedure | ||
The following procedure will re-import legal officers data into the correct backend database. | ||
|
||
### Prerequisite | ||
This [migration](https://github.com/logion-network/logion-backend-ts/blob/main/src/logion/migration/1718188396630-AddLegalOfficers.ts) must be applied on each target backend. | ||
|
||
### Choose an environment | ||
|
||
cd test | ||
or | ||
|
||
cd mvp | ||
|
||
Repeat the step 1-4 for each of the following target hosts: | ||
|
||
For Test: | ||
`root@test-node01`, `root@test-node02` | ||
|
||
For MVP: `root@node02`, `root@node03`, `ubuntu@node09` | ||
|
||
1. Set the HOST var | ||
|
||
```shell | ||
export HOST=root@node02 | ||
``` | ||
|
||
2. Upload file and connect to host | ||
|
||
```shell | ||
FULL_HOST=$HOST.logion.network; \ | ||
echo $FULL_HOST ; \ | ||
scp legal-officers.sql $FULL_HOST:/tmp ; \ | ||
scp keep-hosted-llos-$HOST.sql $FULL_HOST:/tmp ; \ | ||
ssh $FULL_HOST | ||
``` | ||
|
||
3. Import data | ||
Run the following commands on the host | ||
```shell | ||
cd logion_docker | ||
docker-compose exec -T private-database psql -U postgres postgres < /tmp/legal-officers.sql | ||
docker-compose exec -T private-database psql -U postgres postgres < /tmp/keep-hosted-llos*.sql | ||
rm /tmp/*.sql | ||
``` | ||
|
||
4. Exit the host |
5 changes: 5 additions & 0 deletions
5
migrate-to-backend/test/keep-hosted-llos-root@test-node01.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
DELETE FROM legal_officer WHERE (1=1 | ||
AND address <> '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY' -- Alice | ||
); | ||
SELECT address, first_name | ||
FROM legal_officer ; |
6 changes: 6 additions & 0 deletions
6
migrate-to-backend/test/keep-hosted-llos-root@test-node02.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
DELETE FROM legal_officer WHERE (1=1 | ||
AND address <> '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty' -- Bob | ||
AND address <> '5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y' -- Charlie | ||
); | ||
SELECT address, first_name | ||
FROM legal_officer ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
-- | ||
-- PostgreSQL database dump | ||
-- | ||
|
||
-- Dumped from database version 12.9 (Debian 12.9-1.pgdg110+1) | ||
-- Dumped by pg_dump version 12.9 (Debian 12.9-1.pgdg110+1) | ||
|
||
SET statement_timeout = 0; | ||
SET lock_timeout = 0; | ||
SET idle_in_transaction_session_timeout = 0; | ||
SET client_encoding = 'UTF8'; | ||
SET standard_conforming_strings = on; | ||
SELECT pg_catalog.set_config('search_path', '', false); | ||
SET check_function_bodies = false; | ||
SET xmloption = content; | ||
SET client_min_messages = warning; | ||
SET row_security = off; | ||
|
||
-- | ||
-- Data for Name: legal_officer; Type: TABLE DATA; Schema: public; Owner: postgres | ||
-- | ||
|
||
INSERT INTO public.legal_officer (address, first_name, last_name, email, phone_number, company, line1, line2, postal_code, city, country, additional_details) VALUES ('5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY', 'Alice', 'Logion', 'alice@logion.network', '+1234', '', '', '', '', '', '', ''); | ||
INSERT INTO public.legal_officer (address, first_name, last_name, email, phone_number, company, line1, line2, postal_code, city, country, additional_details) VALUES ('5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty', 'Bob', 'Logion', 'bob@logion.network', '+1234', '', '', '', '', '', '', ''); | ||
INSERT INTO public.legal_officer (address, first_name, last_name, email, phone_number, company, line1, line2, postal_code, city, country, additional_details) VALUES ('5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y', 'Charlie', 'Logion', 'charlie@logion.network', '+1234', '', '', '', '', '', '', ''); | ||
|
||
|
||
-- | ||
-- PostgreSQL database dump complete | ||
-- | ||
|