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
- New columns on companies: membership_status (active/resigned/suspended/exempt), resignation_date, fee_included_in_parent (boolean) - Migration 094: sets KORNIX as resigned, PZU resignation_date=2026-03-02, links subsidiaries (Pelmar→P&P, Chopin TV→TTM), adds missing companies (Maciej Hałas, Markisol as resigned; Fresh Bike, Jantar, WW Glass as active subsidiaries) - Admin fees panel and board view now exclude fee_included_in_parent companies - Added source Excel file: data/skladki_czlonkowskie_2022_2025.xlsx Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
71 lines
3.2 KiB
SQL
71 lines
3.2 KiB
SQL
-- Migration 094: Add membership status fields to companies
|
|
-- membership_status: active, resigned, suspended, exempt (independent from portal visibility 'status')
|
|
-- resignation_date: when company left the chamber
|
|
-- fee_included_in_parent: subsidiary whose fees are covered by parent company
|
|
|
|
ALTER TABLE companies ADD COLUMN IF NOT EXISTS membership_status VARCHAR(20) DEFAULT 'active';
|
|
ALTER TABLE companies ADD COLUMN IF NOT EXISTS resignation_date DATE;
|
|
ALTER TABLE companies ADD COLUMN IF NOT EXISTS fee_included_in_parent BOOLEAN DEFAULT FALSE;
|
|
|
|
-- Set membership_status='active' for all currently active companies
|
|
UPDATE companies SET membership_status = 'active' WHERE status = 'active' AND membership_status IS NULL;
|
|
|
|
-- Set membership_status='resigned' for known inactive companies that resigned
|
|
UPDATE companies SET membership_status = 'resigned' WHERE status = 'inactive' AND membership_status IS NULL;
|
|
|
|
-- === RESIGNATIONS ===
|
|
|
|
-- KORNIX (id=82): rezygnacja z końcem 2025
|
|
UPDATE companies SET membership_status = 'resigned', status = 'inactive' WHERE id = 82;
|
|
|
|
-- PZU TFI (id=100): rezygnacja 02.03.2026 (already inactive)
|
|
UPDATE companies SET membership_status = 'resigned', resignation_date = '2026-03-02' WHERE id = 100;
|
|
|
|
-- === SUBSIDIARIES (fee included in parent) ===
|
|
|
|
-- Pelmar (id=51) → P&P (id=84)
|
|
UPDATE companies SET parent_company_id = 84, fee_included_in_parent = TRUE WHERE id = 51;
|
|
|
|
-- Chopin Telewizja Kablowa (id=25) → TTM (id=92)
|
|
UPDATE companies SET parent_company_id = 92, fee_included_in_parent = TRUE WHERE id = 25;
|
|
|
|
-- === NEW COMPANIES: Resigned members ===
|
|
|
|
-- MACIEJ HAŁAS - rezygnacja
|
|
INSERT INTO companies (name, slug, status, membership_status, data_quality)
|
|
VALUES ('Maciej Hałas', 'maciej-halas', 'inactive', 'resigned', 'basic')
|
|
ON CONFLICT (slug) DO NOTHING;
|
|
|
|
-- MARKISOL - rezygnacja 30.01.2025
|
|
INSERT INTO companies (name, slug, status, membership_status, resignation_date, data_quality)
|
|
VALUES ('Markisol', 'markisol', 'inactive', 'resigned', '2025-01-30', 'basic')
|
|
ON CONFLICT (slug) DO NOTHING;
|
|
|
|
-- === NEW COMPANIES: Active subsidiaries ===
|
|
|
|
-- FRESH BIKE → Eura-Tech (id=34)
|
|
INSERT INTO companies (name, slug, status, membership_status, parent_company_id, fee_included_in_parent, data_quality)
|
|
VALUES ('Fresh Bike', 'fresh-bike', 'active', 'active', 34, TRUE, 'basic')
|
|
ON CONFLICT (slug) DO NOTHING;
|
|
|
|
-- JANTAR - centrum handlowe → Eura-Tech (id=34)
|
|
INSERT INTO companies (name, slug, status, membership_status, parent_company_id, fee_included_in_parent, data_quality)
|
|
VALUES ('Jantar - Centrum Handlowe', 'jantar-centrum-handlowe', 'active', 'active', 34, TRUE, 'basic')
|
|
ON CONFLICT (slug) DO NOTHING;
|
|
|
|
-- WW GLASS → Lenap Hale (id=83)
|
|
INSERT INTO companies (name, slug, status, membership_status, parent_company_id, fee_included_in_parent, data_quality)
|
|
VALUES ('WW Glass', 'ww-glass', 'active', 'active', 83, TRUE, 'basic')
|
|
ON CONFLICT (slug) DO NOTHING;
|
|
|
|
-- === PZU: Waive fees from April 2026 onwards ===
|
|
UPDATE membership_fees
|
|
SET status = 'waived', notes = 'Rezygnacja z członkostwa od 02.03.2026'
|
|
WHERE company_id = 100
|
|
AND fee_year = 2026
|
|
AND fee_month >= 4
|
|
AND status IN ('pending', 'overdue');
|
|
|
|
-- Grant permissions
|
|
GRANT ALL ON TABLE companies TO nordabiz_app;
|