diff --git a/charts/my-recipes-chart/templates/db-schema-configmap.yaml b/charts/my-recipes-chart/templates/db-schema-configmap.yaml index 0dcc273..cc8c8e2 100644 --- a/charts/my-recipes-chart/templates/db-schema-configmap.yaml +++ b/charts/my-recipes-chart/templates/db-schema-configmap.yaml @@ -81,3 +81,52 @@ data: ALTER TABLE users ALTER COLUMN display_name SET NOT NULL; END IF; END $$; + + DO $$ + BEGIN + IF NOT EXISTS ( + SELECT 1 FROM information_schema.columns + WHERE table_name = 'users' AND column_name = 'is_admin' + ) THEN + ALTER TABLE users ADD COLUMN is_admin BOOLEAN DEFAULT FALSE; + END IF; + END $$; + + -- Create grocery lists table + CREATE TABLE IF NOT EXISTS grocery_lists ( + id SERIAL PRIMARY KEY, + name TEXT NOT NULL, + items TEXT[] NOT NULL DEFAULT '{}', + owner_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE, + is_pinned BOOLEAN DEFAULT FALSE, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP + ); + + -- Create grocery list shares table + CREATE TABLE IF NOT EXISTS grocery_list_shares ( + id SERIAL PRIMARY KEY, + list_id INTEGER NOT NULL REFERENCES grocery_lists(id) ON DELETE CASCADE, + shared_with_user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE, + can_edit BOOLEAN DEFAULT FALSE, + shared_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + UNIQUE(list_id, shared_with_user_id) + ); + + CREATE INDEX IF NOT EXISTS idx_grocery_lists_owner_id ON grocery_lists (owner_id); + CREATE INDEX IF NOT EXISTS idx_grocery_list_shares_list_id ON grocery_list_shares (list_id); + CREATE INDEX IF NOT EXISTS idx_grocery_list_shares_user_id ON grocery_list_shares (shared_with_user_id); + + -- Create notifications table + CREATE TABLE IF NOT EXISTS notifications ( + id SERIAL PRIMARY KEY, + user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE, + type TEXT NOT NULL, + message TEXT NOT NULL, + related_id INTEGER, + is_read BOOLEAN DEFAULT FALSE, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP + ); + + CREATE INDEX IF NOT EXISTS idx_notifications_user_id ON notifications (user_id); + CREATE INDEX IF NOT EXISTS idx_notifications_is_read ON notifications (is_read); diff --git a/manifests/my-recipes/values.yaml b/manifests/my-recipes/values.yaml index 5bd7499..bbc296b 100644 --- a/manifests/my-recipes/values.yaml +++ b/manifests/my-recipes/values.yaml @@ -8,7 +8,7 @@ backend: image: repository: harbor.dvirlabs.com/my-apps/my-recipes-backend pullPolicy: Always - tag: develop-ba7d0c9 + tag: latest service: type: ClusterIP port: 8000 @@ -45,7 +45,7 @@ frontend: image: repository: harbor.dvirlabs.com/my-apps/my-recipes-frontend pullPolicy: Always - tag: develop-ba7d0c9 + tag: latest service: type: ClusterIP port: 80