40 lines
1.7 KiB
SQL
40 lines
1.7 KiB
SQL
CREATE SCHEMA IF NOT EXISTS fc;
|
|
|
|
--DROP TABLE IF EXISTS fc.target_meta;
|
|
CREATE TABLE IF NOT EXISTS fc.target_meta (
|
|
schema text
|
|
,tname text
|
|
,cname text
|
|
,opos int
|
|
,func text
|
|
,fkey text
|
|
,fcol text
|
|
,dtype text
|
|
,appcol text
|
|
,pretty text
|
|
);
|
|
|
|
--ALTER TABLE fc.target_meta DROP CONSTRAINT IF EXISTS target_meta_pk;
|
|
ALTER TABLE fc.target_meta ADD CONSTRAINT target_meta_pk PRIMARY KEY (schema, tname, cname);
|
|
|
|
COMMENT ON TABLE fc.target_meta IS 'target table layout info';
|
|
COMMENT ON COLUMN fc.target_meta.schema IS 'schema of target sales data table';
|
|
COMMENT ON COLUMN fc.target_meta.tname IS 'table_name of target sales data table';
|
|
COMMENT ON COLUMN fc.target_meta.cname IS 'column name';
|
|
COMMENT ON COLUMN fc.target_meta.opos IS 'ordinal position of column';
|
|
COMMENT ON COLUMN fc.target_meta.func IS 'a functional entity (like customer, part number) that master tables will be build from';
|
|
COMMENT ON COLUMN fc.target_meta.fcol IS 'associated field from the master data table if it is different (oseas would refer to ssyr in fc.perd)';
|
|
COMMENT ON COLUMN fc.target_meta.fkey IS 'primary key for functional entity';
|
|
COMMENT ON COLUMN fc.target_meta.dtype IS 'data type of the sales table column';
|
|
COMMENT ON COLUMN fc.target_meta.appcol IS 'supply column name to be used for application variables - (specifcy the order date column)';
|
|
COMMENT ON COLUMN fc.target_meta.pretty IS 'the presentation name of the column';
|
|
|
|
CREATE TABLE IF NOT EXISTS fc.log (
|
|
id int GENERATED ALWAYS AS IDENTITY
|
|
,doc jsonb
|
|
);
|
|
|
|
COMMENT ON TABLE fc.log IS 'forecast change log';
|
|
|
|
CREATE TABLE IF NOT EXISTS fc.sql(cmd text PRIMARY KEY, t text );
|