notXCS/migrations/0004_roles_and_place_access.sql
2026-07-02 15:10:45 +00:00

8 lines
568 B
SQL

ALTER TABLE users ADD COLUMN role INTEGER NOT NULL DEFAULT 1;
CREATE TABLE IF NOT EXISTS place_access (id INTEGER PRIMARY KEY AUTOINCREMENT, placeId TEXT NOT NULL, userId INTEGER NOT NULL, grantedBy INTEGER, createdAt DATETIME DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY(placeId) REFERENCES places(id), FOREIGN KEY(userId) REFERENCES users(id), FOREIGN KEY(grantedBy) REFERENCES users(id), UNIQUE(placeId, userId));
CREATE INDEX IF NOT EXISTS idx_place_access_userId ON place_access(userId);
CREATE INDEX IF NOT EXISTS idx_place_access_placeId ON place_access(placeId);