Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tenant): delegate tenant configuration #280

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading