2020-10-22 01:22:40 -04:00
|
|
|
--assumes schema fc already exists
|
|
|
|
|
2020-12-08 01:30:02 -05:00
|
|
|
--DROP TABLE IF EXISTS fc.target_meta;
|
|
|
|
CREATE TABLE IF NOT EXISTS fc.target_meta (
|
2020-11-09 23:20:46 -05:00
|
|
|
tname text
|
|
|
|
,cname text
|
|
|
|
,opos int
|
|
|
|
,func text
|
|
|
|
,fkey text
|
|
|
|
,pretty text
|
|
|
|
,dtype text
|
|
|
|
,mastcol text
|
|
|
|
,appcol text
|
|
|
|
,dateref text
|
2020-10-22 01:22:40 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
--ALTER TABLE fc.target_meta DROP CONSTRAINT IF EXISTS target_meta_pk;
|
2020-12-08 01:30:02 -05:00
|
|
|
ALTER TABLE fc.target_meta ADD CONSTRAINT IF NOT EXISTS target_meta_pk PRIMARY KEY (tname, cname);
|
2020-10-22 01:22:40 -04:00
|
|
|
|
|
|
|
COMMENT ON TABLE fc.target_meta IS 'target table layout info';
|
2020-11-05 23:50:02 -05:00
|
|
|
COMMENT ON COLUMN fc.target_meta.tname IS 'schema.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.fkey IS 'primary key for functional entity';
|
|
|
|
COMMENT ON COLUMN fc.target_meta.pretty IS 'the presentation name of the column';
|
|
|
|
COMMENT ON COLUMN fc.target_meta.dtype IS 'data type of the sales table column';
|
|
|
|
COMMENT ON COLUMN fc.target_meta.mastcol 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.appcol IS 'supply column name to be used for application variables - (specifcy the order date column)';
|
2020-11-09 23:20:46 -05:00
|
|
|
COMMENT ON COLUMN fc.target_meta.dateref IS 'reference to the relevant hard coded perd table column for dates';
|
2020-12-08 01:30:02 -05:00
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS fc.log (
|
|
|
|
id int GENERATED ALWAYS AS IDENTITY
|
|
|
|
,doc jsonb
|
|
|
|
);
|
|
|
|
|
|
|
|
COMMENT ON TABLE fc.log IS 'forecast change log';
|