Clean up SQL

This commit is contained in:
Janus C. H. Knudsen 2025-02-03 17:58:51 +01:00
parent 5c181936d8
commit cdd645bb3b
4 changed files with 16 additions and 80 deletions

View file

@ -127,53 +127,18 @@ COMMENT ON COLUMN app_configuration_history.changed_at IS 'When the change occur
COMMENT ON COLUMN app_configuration_history.changed_by IS 'User who made the change';
```sql
DELETE from ptmain.app_configuration
-- Email templates configuration
INSERT INTO app_configuration (key, value, label, content_type, valid_from, expires_at) VALUES
('Email:Templates:Welcome',
'{"subject":"Velkommen til vores platform","template":"welcome-dk.html","sender":"velkommen@firma.dk"}',
'Email Templates',
'application/json',
'2024-01-01T00:00:00Z',
NULL);
select * from app_configuration_history
update app_configuration
set label = 'test'
INSERT INTO app_configuration (key, value, label, content_type, valid_from, expires_at) VALUES
('Email:Templates:Password',
'{"subject":"Nulstil dit kodeord","template":"reset-password-dk.html","sender":"support@firma.dk"}',
'Email Templates',
'application/json',
'2024-01-01T00:00:00Z',
NULL);
-- API configuration
INSERT INTO app_configuration (key, value, label, content_type, valid_from, expires_at) VALUES
('Api:Endpoints:BaseUrl',
'{"production":"https://api.firma.dk","staging":"https://staging-api.firma.dk"}',
'API Settings',
'application/json',
'2024-01-01T00:00:00Z',
NULL);
-- Feature flags
INSERT INTO app_configuration (key, value, label, content_type, valid_from, expires_at) VALUES
('Features:NewUI',
'{"enabled":false,"rolloutPercentage":0,"description":"New React based UI"}',
'Feature Flags',
'application/json',
'2024-02-01T00:00:00Z',
'2024-12-31T23:59:59Z');
-- System settings
INSERT INTO app_configuration (key, value, label, content_type, valid_from, expires_at) VALUES
('System:Cache',
'{"timeoutMinutes":15,"maxItems":1000,"distributed":true}',
'System Settings',
'application/json',
'2024-01-01T00:00:00Z',
NULL);
```
INSERT INTO ptmain.app_configuration ("key",value,"label",content_type,valid_from,expires_at,created_at,modified_at,etag) VALUES
('Debug','true',NULL,'text/plain',NULL,NULL,'2025-02-02 14:25:22.200058+01','2025-02-02 14:25:22.200058+01','f1348731-9396-4f1d-b40a-7fbd23a897d2'::uuid),
('Database:ConnectionString','"Server=db.example.com;Port=5432"',NULL,'text/plain',NULL,NULL,'2025-02-02 14:25:22.200058+01','2025-02-02 14:25:22.200058+01','2aa0bc3e-fa24-449a-8f25-a76d9b4d535e'::uuid),
('Database:Timeout','30',NULL,'text/plain',NULL,NULL,'2025-02-02 14:25:22.200058+01','2025-02-02 14:25:22.200058+01','d25ebb14-49f6-4e33-9ac7-a3253705d0fb'::uuid),
('Database:UseSSL','true',NULL,'text/plain',NULL,NULL,'2025-02-02 14:25:22.200058+01','2025-02-02 14:25:22.200058+01','f4d52ec4-b723-4561-9b18-0e7a68b89a17'::uuid),
('Logging:FileOptions','{"Path": "/var/logs/app.log", "MaxSizeMB": 100, "RetentionDays": 7}',NULL,'text/plain',NULL,NULL,'2025-02-02 14:25:22.200058+01','2025-02-02 14:25:22.200058+01','06c0891d-a860-4acc-917a-d0877f511c1b'::uuid),
('Features:Experimental','{"Enabled": true, "RolloutPercentage": 25, "AllowedUserGroups": ["beta"]}',NULL,'text/plain',NULL,NULL,'2025-02-02 14:25:22.200058+01','2025-02-02 14:25:22.200058+01','0136fdef-51d9-4909-82ef-f72053ce6d6d'::uuid),
('API:Endpoints','"/api/users"',NULL,'text/plain',NULL,NULL,'2025-02-02 14:25:22.200058+01','2025-02-02 14:25:22.200058+01','fe362b69-a486-48ad-9165-2e623e2e6f70'::uuid),
('API:Endpoints','"/api/products"',NULL,'text/plain',NULL,NULL,'2025-02-02 14:25:22.200058+01','2025-02-02 14:25:22.200058+01','c087e2d4-1f38-4814-b4dd-f30c463dc6d1'::uuid);

View file

@ -13,34 +13,5 @@ ALTER DEFAULT PRIVILEGES IN SCHEMA ptmain
GRANT ALL PRIVILEGES ON TABLES TO sathumper;
-- prod.app_configuration definition
-- Drop table
-- DROP TABLE prod.app_configuration;
CREATE TABLE prod.app_configuration (
id bigserial NOT NULL,
"key" varchar(255) NOT NULL,
value text NULL,
"label" varchar(255) NULL,
content_type varchar(255) DEFAULT 'text/plain'::character varying NULL,
expires_at timestamptz NULL,
created_at timestamptz DEFAULT CURRENT_TIMESTAMP NULL,
modified_at timestamptz DEFAULT CURRENT_TIMESTAMP NULL,
etag uuid DEFAULT gen_random_uuid() NULL,
CONSTRAINT app_configuration_pkey PRIMARY KEY (id)
);
CREATE UNIQUE INDEX idx_prod_unique_key_label ON prod.app_configuration USING btree (key, COALESCE(label, ''::character varying));