Skip to content

Commit 1cdedd7

Browse files
authored
Merge pull request #33 from joschne/GEOV-178-add-inherited-property-table
Added new table inherited_property to the migrations
2 parents 4a2ee4d + 3ccc3c8 commit 1cdedd7

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
'use strict';
2+
3+
var dbm;
4+
var type;
5+
var seed;
6+
7+
/**
8+
* We receive the dbmigrate dependency from dbmigrate initially.
9+
* This enables us to not have to rely on NODE_PATH.
10+
*/
11+
exports.setup = function(options, seedLink) {
12+
dbm = options.dbmigrate;
13+
type = dbm.dataType;
14+
seed = seedLink;
15+
};
16+
17+
exports.up = function(db, callback) {
18+
const sql = `
19+
20+
CREATE TABLE data_for_history.inherited_property (
21+
dfh_pk_inherited_property integer,
22+
dfh_is_originated_from_property integer,
23+
dfh_inherited_from_class integer,
24+
dfh_identifier_in_namespace text,
25+
dfh_has_domain integer,
26+
dfh_has_range integer,
27+
dfh_creation_time timestamp,
28+
dfh_modification_time timestamp,
29+
dfh_domain_instances_min_quantifier smallint,
30+
dfh_domain_instances_max_quantifier smallint,
31+
dfh_range_instances_min_quantifier smallint,
32+
dfh_range_instances_max_quantifier smallint,
33+
dfh_standard_label varchar(500)
34+
)
35+
INHERITS (data_for_history.entity);
36+
37+
CREATE TRIGGER creation_tmsp
38+
BEFORE INSERT
39+
ON data_for_history.inherited_property
40+
FOR EACH ROW
41+
EXECUTE PROCEDURE commons.tmsp_creation();
42+
43+
CREATE TRIGGER last_modification_tmsp
44+
BEFORE INSERT OR UPDATE
45+
ON data_for_history.inherited_property
46+
FOR EACH ROW
47+
EXECUTE PROCEDURE commons.tmsp_last_modification();
48+
49+
CREATE TRIGGER insert_schema_table_name BEFORE INSERT
50+
ON data_for_history.inherited_property FOR EACH ROW
51+
EXECUTE PROCEDURE commons.insert_schema_table_name();
52+
53+
54+
-- versioning
55+
56+
CREATE TABLE data_for_history.inherited_property_vt (LIKE data_for_history.inherited_property);
57+
58+
CREATE TRIGGER versioning_trigger
59+
BEFORE INSERT OR UPDATE OR DELETE ON data_for_history.inherited_property
60+
FOR EACH ROW EXECUTE PROCEDURE versioning(
61+
'sys_period', 'data_for_history.inherited_property_vt', true
62+
);
63+
`
64+
db.runSql(sql, callback)
65+
66+
};
67+
68+
exports.down = function(db, callback) {
69+
const sql = `
70+
DROP TABLE IF EXISTS data_for_history.inherited_property CASCADE;
71+
DROP TABLE IF EXISTS data_for_history.inherited_property_vt CASCADE;
72+
`
73+
db.runSql(sql, callback)
74+
};
75+
76+
77+
exports._meta = {
78+
"version": 1
79+
};

0 commit comments

Comments
 (0)