Added development readme, dev docker compose, testing db migrations

This commit is contained in:
Peter Grlica
2020-12-13 18:53:18 +01:00
parent 2cbc5605bf
commit 5499d2274d
4 changed files with 217 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
version: "3"
services:
pg:
image: postgres:12.4
environment:
- POSTGRES_PASSWORD=docker
- POSTGRES_USER=docker
ports:
- 5432:5432
volumes:
- ./data/pg:/var/lib/postgresql/data
db:
image: percona:8.0
restart: on-failure
environment:
# To be picked up by percona image when creating the database
# Must match with DB_DSN settings inside .env
MYSQL_DATABASE: corteza
MYSQL_USER: corteza
MYSQL_PASSWORD: rootcorteza
MYSQL_ROOT_PASSWORD: rootcorteza
volumes: [ "./data/db:/var/lib/mysql" ] # use local fs
ports:
- 3306:3306
+86
View File
@@ -0,0 +1,86 @@
== Setup db (postgres)
Add db dsn to .env
[source,bash]
----
DB_DSN=postgres+debug://docker:docker@localhost:5432/corteza?sslmode=disable
----
Start the postgres db
[source,bash]
----
$ docker-compose up -db pg
----
Add testing migrations
[source,bash]
----
$ docker exec -i corteza-server_pg_1 psql -U docker corteza < federation/migration_federation_origin.sql
$ docker exec -i corteza-server_pg_1 psql -U docker corteza < federation/migration_federation_destination.sql
----
== Status
=== Node pairing
=== Structure sync
.List of endpoints
* [x] Show exposed module
* [x] Remove exposed module
* [x] Shared module details
* [x] List of shared/exposed modules
* [ ] Add module as exposed (with mappings)
* [ ] Add mappings to module
* [ ] Show module mappings
* [ ] Update fields on exposed module
Show exposed module::
[source,bash]
----
$ curl -X GET "$BASE_URL/federation/nodes/$NODE_ID/modules/$MODULE_ID/exposed"
----
Remove exposed module::
[source,bash]
----
$ curl -X DELETE "$BASE_URL/federation/nodes/$NODE_ID/modules/$MODULE_ID/exposed"
----
Shared module details::
[source,bash]
----
$ curl -X GET "$BASE_URL/federation/nodes/$NODE_ID/modules/$MODULE_ID/shared"
----
List of shared/exposed modules::
[source,bash]
----
$ curl -X GET "$BASE_URL/federation/nodes/$NODE_ID/modules?exposed"
$ curl -X GET "$BASE_URL/federation/nodes/$NODE_ID/modules?shared"
----
Add module as exposed (with mappings)::
[source,bash]
----
curl -X PUT "$BASE_URL/federation/nodes/$NODE_ID/modules/0/exposed"
----
Add mappings to module::
[source,bash]
----
curl -X PUT "$BASE_URL/federation/nodes/$NODE_ID/modules/$MODULE_ID/mapped"
----
Show module mappings::
[source,bash]
----
curl -X GET "$BASE_URL/federation/nodes/$NODE_ID/modules/$MODULE_ID/mapped"
----
Update fields on exposed module::
[source,bash]
----
curl -X PUT "$BASE_URL/federation/nodes/$NODE_ID/modules/$MODULE_ID/exposed"
----
@@ -0,0 +1,51 @@
-- Pricebook module
-- id | rel_namespace | handle | name | meta | created_at | updated_at | deleted_at
-- --------------------+--------------------+-----------+-----------+------+-------------------------------+------------------------------+------------
-- 196342359342989413 | 196342358990667877 | Pricebook | Pricebook | {} | 2020-09-16 12:06:05.830318+00 | 2020-09-16 12:06:15.24715+00 |
CREATE TABLE IF NOT EXISTS federation_module_shared
(
id BIGINT NOT NULL,
handle varchar(200),
name varchar(64),
rel_node BIGINT,
xref_module BIGINT,
fields jsonb,
PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXISTS federation_module_exposed
(
id BIGINT NOT NULL,
rel_node BIGINT,
rel_compose_module BIGINT,
fields jsonb,
PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXISTS federation_module_mapping
(
federation_module_id BIGINT,
compose_module_id BIGINT,
field_mapping jsonb
);
CREATE TABLE IF NOT EXISTS federation_node
(
id BIGINT NOT NULL,
name varchar(256),
status varchar(64),
structure_status varchar(64),
structure_synced_at varchar(64),
data_status varchar(64),
data_synced_at varchar(64),
PRIMARY KEY(id)
);
INSERT INTO federation_node values ('276342359342989555', 'Node Origin (somewhere else)', 'paired', 'synced', now(), 'synced', now());
INSERT INTO federation_module_shared (id, handle, name, rel_node, xref_module, fields)
VALUES
(206342359342988000, 'Pricebook_on_origin_somewhere_else', 'Pricebook on some other origin (somewhere else)', 276342359342989555, 196342359342989000, NULL)
;
@@ -0,0 +1,56 @@
-- Pricebook module
-- id | rel_namespace | handle | name | meta | created_at | updated_at | deleted_at
-- --------------------+--------------------+-----------+-----------+------+-------------------------------+------------------------------+------------
-- 196342359342989413 | 196342358990667877 | Pricebook | Pricebook | {} | 2020-09-16 12:06:05.830318+00 | 2020-09-16 12:06:15.24715+00 |
CREATE TABLE IF NOT EXISTS federation_module_shared
(
id BIGINT NOT NULL,
handle varchar(200),
name varchar(64),
rel_node BIGINT,
xref_module BIGINT,
fields jsonb,
PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXISTS federation_module_exposed
(
id BIGINT NOT NULL,
rel_node BIGINT,
rel_compose_module BIGINT,
fields jsonb,
PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXISTS federation_module_mapping
(
federation_module_id BIGINT,
compose_module_id BIGINT,
field_mapping jsonb
);
CREATE TABLE IF NOT EXISTS federation_node
(
id BIGINT NOT NULL,
name varchar(256),
status varchar(64),
structure_status varchar(64),
structure_synced_at varchar(64),
data_status varchar(64),
data_synced_at varchar(64),
PRIMARY KEY(id)
);
INSERT INTO federation_node values ('276342359342989444', 'Node Destination (somewhere else)', 'paired', 'synced', now(), 'synced', now());
INSERT INTO federation_module_exposed (id, rel_node, rel_compose_module, fields)
VALUES
(196342359342989000, 276342359342989444, 196342359342989413, NULL)
;
INSERT INTO federation_module_shared (id, handle, name, rel_node, xref_module, fields)
VALUES
(196342359342988000, 'Pricebook_on_origin_somewhere_else', 'Pricebook on some other origin (somewhere else)', 276342359342989444, 123456789012345678, NULL)
;