bmc_hub/app/modules/_template/migrations/001_init.sql
Christian 38fa3b6c0a feat: Add subscriptions lock feature to customers
- Added a new column `subscriptions_locked` to the `customers` table to manage subscription access.
- Implemented a script to create new modules from a template, including updates to various files (module.json, README.md, router.py, views.py, and migration SQL).
- Developed a script to import BMC Office subscriptions from an Excel file into the database, including error handling and statistics reporting.
- Created a script to lookup and update missing CVR numbers using the CVR.dk API.
- Implemented a script to relink Hub customers to e-conomic customer numbers based on name matching.
- Developed scripts to sync CVR numbers from Simply-CRM and vTiger to the local customers database.
2025-12-13 12:06:28 +01:00

38 lines
1.1 KiB
PL/PgSQL

-- Template Module - Initial Migration
-- Opret basis tabeller for template module
-- Items tabel (eksempel)
CREATE TABLE IF NOT EXISTS template_items (
id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
description TEXT,
active BOOLEAN DEFAULT TRUE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Index for performance
CREATE INDEX IF NOT EXISTS idx_template_items_active ON template_items(active);
CREATE INDEX IF NOT EXISTS idx_template_items_created ON template_items(created_at DESC);
-- Trigger for updated_at
CREATE OR REPLACE FUNCTION update_template_items_updated_at()
RETURNS TRIGGER AS $$
BEGIN
NEW.updated_at = CURRENT_TIMESTAMP;
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER trigger_template_items_updated_at
BEFORE UPDATE ON template_items
FOR EACH ROW
EXECUTE FUNCTION update_template_items_updated_at();
-- Indsæt test data (optional)
INSERT INTO template_items (name, description)
VALUES
('Test Item 1', 'This is a test item from template module'),
('Test Item 2', 'Another test item')
ON CONFLICT DO NOTHING;