migrate site id to varchar instead of int
This commit is contained in:
1 parent
61f954a3bd
commit
36639d8c38
16 files changed
+448
-41
No files matched your search
@@ -10,6 +10,7 @@
|
||||
-- is_active true, is_superuser false. Product roles never use is_staff.)
|
||||
--
|
||||
-- user_access → sites → kandang → cycles
|
||||
-- (sites.site_id = farm slug = active_sites.source_site_id when linked)
|
||||
-- kandang → flock → iot_panel
|
||||
-- user_access → api_keys
|
||||
-- user_access → active_sites (managed_by)
|
||||
@@ -103,10 +104,12 @@ CREATE INDEX IF NOT EXISTS idx_active_sites_managed_by_id ON active_sites (manag
|
||||
CREATE INDEX IF NOT EXISTS idx_active_sites_source_site_id ON active_sites (source_site_id);
|
||||
|
||||
-- -----------------------------------------------------------------------------
|
||||
-- 4. Sites
|
||||
-- 4. Sites (HQ farm tree)
|
||||
-- site_id is the farm dashboard Site.site_id slug (e.g. sukawarna-4821).
|
||||
-- When linked, it equals active_sites.source_site_id.
|
||||
-- -----------------------------------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS sites (
|
||||
site_id BIGSERIAL PRIMARY KEY,
|
||||
site_id VARCHAR(64) PRIMARY KEY,
|
||||
site_name VARCHAR(30) NOT NULL,
|
||||
user_id BIGINT NOT NULL REFERENCES user_access (user_id) ON DELETE CASCADE,
|
||||
active_site_id BIGINT UNIQUE REFERENCES active_sites (active_site_id) ON DELETE SET NULL,
|
||||
@@ -123,7 +126,7 @@ CREATE TABLE IF NOT EXISTS kandang (
|
||||
kandang_id BIGSERIAL PRIMARY KEY,
|
||||
kandang_name VARCHAR(30) NOT NULL,
|
||||
feed_in_button_urls JSONB NOT NULL DEFAULT '[]'::jsonb,
|
||||
site_id BIGINT NOT NULL REFERENCES sites (site_id) ON DELETE CASCADE,
|
||||
site_id VARCHAR(64) NOT NULL REFERENCES sites (site_id) ON DELETE CASCADE,
|
||||
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user