nordabiz/database/migrations/073_social_config_per_company.sql
Maciej Pienczyn d8e0162e01
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
feat: add per-company Facebook configuration to Social Publisher
Social Publisher now supports multi-company FB publishing via OAuth.
Each company can connect its own Facebook page through the existing
OAuth framework. Includes discover-pages/select-page endpoints,
per-company settings UI, and publishing_company_id on posts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 08:15:36 +01:00

18 lines
907 B
SQL

-- Migration 073: Social Media Config per Company
-- Adds company_id to social_media_config for multi-tenant publishing
-- Adds publishing_company_id to social_media_posts
-- 1. Add company_id column to social_media_config
ALTER TABLE social_media_config ADD COLUMN IF NOT EXISTS company_id INTEGER REFERENCES companies(id);
-- 2. Drop old unique constraint (platform-only) and add compound unique
ALTER TABLE social_media_config DROP CONSTRAINT IF EXISTS social_media_config_platform_key;
ALTER TABLE social_media_config ADD CONSTRAINT uq_social_config_platform_company UNIQUE(platform, company_id);
-- 3. Add publishing_company_id to social_media_posts
ALTER TABLE social_media_posts ADD COLUMN IF NOT EXISTS publishing_company_id INTEGER REFERENCES companies(id);
-- 4. Ensure permissions
GRANT ALL ON TABLE social_media_config TO nordabiz_app;
GRANT ALL ON TABLE social_media_posts TO nordabiz_app;