- 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.
38 lines
1.1 KiB
PL/PgSQL
38 lines
1.1 KiB
PL/PgSQL
-- Test Module Module - Initial Migration
|
|
-- Opret basis tabeller for template module
|
|
|
|
-- Items tabel (eksempel)
|
|
CREATE TABLE IF NOT EXISTS test_module_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_test_module_items_active ON test_module_items(active);
|
|
CREATE INDEX IF NOT EXISTS idx_test_module_items_created ON test_module_items(created_at DESC);
|
|
|
|
-- Trigger for updated_at
|
|
CREATE OR REPLACE FUNCTION update_test_module_items_updated_at()
|
|
RETURNS TRIGGER AS $$
|
|
BEGIN
|
|
NEW.updated_at = CURRENT_TIMESTAMP;
|
|
RETURN NEW;
|
|
END;
|
|
$$ LANGUAGE plpgsql;
|
|
|
|
CREATE TRIGGER trigger_test_module_items_updated_at
|
|
BEFORE UPDATE ON test_module_items
|
|
FOR EACH ROW
|
|
EXECUTE FUNCTION update_test_module_items_updated_at();
|
|
|
|
-- Indsæt test data (optional)
|
|
INSERT INTO test_module_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;
|