Skip to content

Commit

Permalink
feat(tenant): delegate tenant configuration (#280)
Browse files Browse the repository at this point in the history
so we can have meetings shared between domains
  • Loading branch information
stakach authored Jan 21, 2025
1 parent 0590c84 commit cc603f7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-- +micrate Up
-- SQL in section 'Up' is executed when this migration is applied

ALTER TABLE tenants ADD COLUMN parent_id BIGINT DEFAULT NULL;

ALTER TABLE tenants ADD CONSTRAINT fk_tenants_parent_id
FOREIGN KEY (parent_id)
REFERENCES tenants(id)
ON DELETE CASCADE;

CREATE INDEX IF NOT EXISTS index_tenants_parent_id_idx ON "tenants" USING HASH (parent_id);

-- +micrate Down
-- SQL section 'Down' is executed when this migration is rolled back

ALTER TABLE tenants DROP CONSTRAINT fk_tenants_parent_id;
DROP INDEX IF EXISTS index_tenants_parent_id_idx;
ALTER TABLE tenants DROP COLUMN parent_id;
2 changes: 2 additions & 0 deletions src/placeos-models/tenant.cr
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ module PlaceOS::Model
class Tenant < ModelWithAutoKey
table :tenants

belongs_to Tenant, foreign_key: "parent_id", association_name: "parent"

attribute name : String?
attribute domain : String
attribute email_domain : String? = nil
Expand Down

0 comments on commit cc603f7

Please sign in to comment.