Skip to content

Commit cc603f7

Browse files
authored
feat(tenant): delegate tenant configuration (#280)
so we can have meetings shared between domains
1 parent 0590c84 commit cc603f7

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
-- +micrate Up
2+
-- SQL in section 'Up' is executed when this migration is applied
3+
4+
ALTER TABLE tenants ADD COLUMN parent_id BIGINT DEFAULT NULL;
5+
6+
ALTER TABLE tenants ADD CONSTRAINT fk_tenants_parent_id
7+
FOREIGN KEY (parent_id)
8+
REFERENCES tenants(id)
9+
ON DELETE CASCADE;
10+
11+
CREATE INDEX IF NOT EXISTS index_tenants_parent_id_idx ON "tenants" USING HASH (parent_id);
12+
13+
-- +micrate Down
14+
-- SQL section 'Down' is executed when this migration is rolled back
15+
16+
ALTER TABLE tenants DROP CONSTRAINT fk_tenants_parent_id;
17+
DROP INDEX IF EXISTS index_tenants_parent_id_idx;
18+
ALTER TABLE tenants DROP COLUMN parent_id;

src/placeos-models/tenant.cr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ module PlaceOS::Model
99
class Tenant < ModelWithAutoKey
1010
table :tenants
1111

12+
belongs_to Tenant, foreign_key: "parent_id", association_name: "parent"
13+
1214
attribute name : String?
1315
attribute domain : String
1416
attribute email_domain : String? = nil

0 commit comments

Comments
 (0)