feature: add company and link person to company and workspace

This commit is contained in:
Sammy Teillet
2023-04-20 12:07:12 +02:00
parent 79f274c355
commit 63c31b4290
17 changed files with 46 additions and 0 deletions

View File

@ -1,3 +1,10 @@
table:
name: person
schema: public
object_relationships:
- name: company
using:
foreign_key_constraint_on: company_id
- name: workspace
using:
foreign_key_constraint_on: workspace_id

View File

@ -0,0 +1,3 @@
table:
name: company
schema: public

View File

@ -1,2 +1,3 @@
- "!include public_company.yaml"
- "!include public_person.yaml"
- "!include public_workspaces.yaml"

View File

@ -0,0 +1,4 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "public"."person" add column "workspace_id" integer
-- not null;

View File

@ -0,0 +1,2 @@
alter table "public"."person" add column "workspace_id" integer
not null;

View File

@ -0,0 +1 @@
alter table "public"."person" drop constraint "person_workspace_id_fkey";

View File

@ -0,0 +1,5 @@
alter table "public"."person"
add constraint "person_workspace_id_fkey"
foreign key ("workspace_id")
references "public"."workspaces"
("id") on update restrict on delete restrict;

View File

@ -0,0 +1 @@
DROP TABLE "public"."company";

View File

@ -0,0 +1 @@
CREATE TABLE "public"."company" ("id" serial NOT NULL, "company_name" text NOT NULL, "company_domain" text NOT NULL, "workspace_id" integer NOT NULL, PRIMARY KEY ("id") , FOREIGN KEY ("workspace_id") REFERENCES "public"."workspaces"("id") ON UPDATE restrict ON DELETE restrict);

View File

@ -0,0 +1,4 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "public"."person" add column "company_id" integer
-- null;

View File

@ -0,0 +1,2 @@
alter table "public"."person" add column "company_id" integer
null;

View File

@ -0,0 +1 @@
alter table "public"."person" drop constraint "person_company_id_fkey";

View File

@ -0,0 +1,5 @@
alter table "public"."person"
add constraint "person_company_id_fkey"
foreign key ("company_id")
references "public"."company"
("id") on update restrict on delete restrict;

View File

@ -0,0 +1,2 @@
alter table "public"."person" alter column "company_domain" drop not null;
alter table "public"."person" add column "company_domain" text;

View File

@ -0,0 +1 @@
alter table "public"."person" drop column "company_domain" cascade;

View File

@ -0,0 +1,4 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "public"."person" add column "email" text
-- null;

View File

@ -0,0 +1,2 @@
alter table "public"."person" add column "email" text
null;