Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 2 additions & 23 deletions data_files/example_dbs/materials.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1548,16 +1548,7 @@ INSERT INTO "time_season" VALUES(2020,9,'summer',NULL);
INSERT INTO "time_season" VALUES(2020,10,'autumn',NULL);
INSERT INTO "time_season" VALUES(2020,11,'winter',NULL);
INSERT INTO "time_season" VALUES(2020,12,'spring',NULL);
CREATE TABLE time_season_all
(
period INTEGER
REFERENCES time_period (period),
sequence INTEGER,
season TEXT
REFERENCES season_label (season),
notes TEXT,
PRIMARY KEY (period, sequence, season)
);

CREATE TABLE time_season_sequential
(
period INTEGER REFERENCES time_period (period),
Expand All @@ -1569,19 +1560,7 @@ CREATE TABLE time_season_sequential
PRIMARY KEY (period, sequence, seas_seq, season),
CHECK (num_days > 0)
);
CREATE TABLE time_season_to_sequential
(
period INTEGER
REFERENCES time_period (period),
sequence INTEGER,
seas_seq TEXT,
season TEXT
REFERENCES season_label (season),
num_days REAL NOT NULL,
notes TEXT,
PRIMARY KEY (period, sequence, seas_seq, season),
CHECK (num_days > 0)
);

CREATE TABLE time_segment_fraction
(
period INTEGER
Expand Down
25 changes: 2 additions & 23 deletions data_files/example_dbs/morris_utopia.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1540,16 +1540,7 @@ INSERT INTO "time_season" VALUES(2000,1,'inter',NULL);
INSERT INTO "time_season" VALUES(2010,2,'summer',NULL);
INSERT INTO "time_season" VALUES(2010,3,'winter',NULL);
INSERT INTO "time_season" VALUES(2010,1,'inter',NULL);
CREATE TABLE time_season_all
(
period INTEGER
REFERENCES time_period (period),
sequence INTEGER,
season TEXT
REFERENCES season_label (season),
notes TEXT,
PRIMARY KEY (period, sequence, season)
);

CREATE TABLE time_season_sequential
(
period INTEGER REFERENCES time_period (period),
Expand All @@ -1561,19 +1552,7 @@ CREATE TABLE time_season_sequential
PRIMARY KEY (period, sequence, seas_seq, season),
CHECK (num_days > 0)
);
CREATE TABLE time_season_to_sequential
(
period INTEGER
REFERENCES time_period (period),
sequence INTEGER,
seas_seq TEXT,
season TEXT
REFERENCES season_label (season),
num_days REAL NOT NULL,
notes TEXT,
PRIMARY KEY (period, sequence, seas_seq, season),
CHECK (num_days > 0)
);

CREATE TABLE time_segment_fraction
(
period INTEGER
Expand Down
25 changes: 2 additions & 23 deletions data_files/example_dbs/seasonal_storage.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1085,16 +1085,7 @@ CREATE TABLE time_season
);
INSERT INTO "time_season" VALUES(2000,0,'charge',NULL);
INSERT INTO "time_season" VALUES(2000,1,'discharge',NULL);
CREATE TABLE time_season_all
(
period INTEGER
REFERENCES time_period (period),
sequence INTEGER,
season TEXT
REFERENCES season_label (season),
notes TEXT,
PRIMARY KEY (period, sequence, season)
);

CREATE TABLE time_season_sequential
(
period INTEGER REFERENCES time_period (period),
Expand All @@ -1120,19 +1111,7 @@ INSERT INTO "time_season_sequential" VALUES(2000,11,'apr_w3','charge',7.0,NULL);
INSERT INTO "time_season_sequential" VALUES(2000,12,'apr_w4','discharge',7.0,NULL);
INSERT INTO "time_season_sequential" VALUES(2000,13,'apr_29th','charge',1.0,NULL);
INSERT INTO "time_season_sequential" VALUES(2000,14,'apr_30th','discharge',1.0,NULL);
CREATE TABLE time_season_to_sequential
(
period INTEGER
REFERENCES time_period (period),
sequence INTEGER,
seas_seq TEXT,
season TEXT
REFERENCES season_label (season),
num_days REAL NOT NULL,
notes TEXT,
PRIMARY KEY (period, sequence, seas_seq, season),
CHECK (num_days > 0)
);

CREATE TABLE time_segment_fraction
(
period INTEGER
Expand Down
25 changes: 2 additions & 23 deletions data_files/example_dbs/survival_curve.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1175,16 +1175,7 @@ INSERT INTO "time_season" VALUES(2035,2,'s',NULL);
INSERT INTO "time_season" VALUES(2040,3,'s',NULL);
INSERT INTO "time_season" VALUES(2045,4,'s',NULL);
INSERT INTO "time_season" VALUES(2050,5,'s',NULL);
CREATE TABLE time_season_all
(
period INTEGER
REFERENCES time_period (period),
sequence INTEGER,
season TEXT
REFERENCES season_label (season),
notes TEXT,
PRIMARY KEY (period, sequence, season)
);

CREATE TABLE time_season_sequential
(
period INTEGER REFERENCES time_period (period),
Expand All @@ -1196,19 +1187,7 @@ CREATE TABLE time_season_sequential
PRIMARY KEY (period, sequence, seas_seq, season),
CHECK (num_days > 0)
);
CREATE TABLE time_season_to_sequential
(
period INTEGER
REFERENCES time_period (period),
sequence INTEGER,
seas_seq TEXT,
season TEXT
REFERENCES season_label (season),
num_days REAL NOT NULL,
notes TEXT,
PRIMARY KEY (period, sequence, seas_seq, season),
CHECK (num_days > 0)
);

CREATE TABLE time_segment_fraction
(
period INTEGER
Expand Down
25 changes: 2 additions & 23 deletions data_files/example_dbs/test_system.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1529,16 +1529,7 @@ INSERT INTO "time_season" VALUES(2030,1,'spring',NULL);
INSERT INTO "time_season" VALUES(2030,2,'summer',NULL);
INSERT INTO "time_season" VALUES(2030,3,'fall',NULL);
INSERT INTO "time_season" VALUES(2030,4,'winter',NULL);
CREATE TABLE time_season_all
(
period INTEGER
REFERENCES time_period (period),
sequence INTEGER,
season TEXT
REFERENCES season_label (season),
notes TEXT,
PRIMARY KEY (period, sequence, season)
);

CREATE TABLE time_season_sequential
(
period INTEGER REFERENCES time_period (period),
Expand All @@ -1550,19 +1541,7 @@ CREATE TABLE time_season_sequential
PRIMARY KEY (period, sequence, seas_seq, season),
CHECK (num_days > 0)
);
CREATE TABLE time_season_to_sequential
(
period INTEGER
REFERENCES time_period (period),
sequence INTEGER,
seas_seq TEXT,
season TEXT
REFERENCES season_label (season),
num_days REAL NOT NULL,
notes TEXT,
PRIMARY KEY (period, sequence, seas_seq, season),
CHECK (num_days > 0)
);

CREATE TABLE time_segment_fraction
(
period INTEGER
Expand Down
25 changes: 2 additions & 23 deletions data_files/example_dbs/utopia.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1537,16 +1537,7 @@ INSERT INTO "time_season" VALUES(2000,3,'winter',NULL);
INSERT INTO "time_season" VALUES(2010,1,'inter',NULL);
INSERT INTO "time_season" VALUES(2010,2,'summer',NULL);
INSERT INTO "time_season" VALUES(2010,3,'winter',NULL);
CREATE TABLE time_season_all
(
period INTEGER
REFERENCES time_period (period),
sequence INTEGER,
season TEXT
REFERENCES season_label (season),
notes TEXT,
PRIMARY KEY (period, sequence, season)
);

CREATE TABLE time_season_sequential
(
period INTEGER REFERENCES time_period (period),
Expand All @@ -1558,19 +1549,7 @@ CREATE TABLE time_season_sequential
PRIMARY KEY (period, sequence, seas_seq, season),
CHECK (num_days > 0)
);
CREATE TABLE time_season_to_sequential
(
period INTEGER
REFERENCES time_period (period),
sequence INTEGER,
seas_seq TEXT,
season TEXT
REFERENCES season_label (season),
num_days REAL NOT NULL,
notes TEXT,
PRIMARY KEY (period, sequence, seas_seq, season),
CHECK (num_days > 0)
);

CREATE TABLE time_segment_fraction
(
period INTEGER
Expand Down
23 changes: 0 additions & 23 deletions data_files/temoa_schema_v4.sql
Original file line number Diff line number Diff line change
Expand Up @@ -959,29 +959,6 @@ CREATE TABLE IF NOT EXISTS time_period
flag TEXT
REFERENCES time_period_type (label)
);
CREATE TABLE IF NOT EXISTS time_season_all
(
period INTEGER
REFERENCES time_period (period),
sequence INTEGER,
season TEXT
REFERENCES season_label (season),
notes TEXT,
PRIMARY KEY (period, sequence, season)
);
CREATE TABLE IF NOT EXISTS time_season_to_sequential
(
period INTEGER
REFERENCES time_period (period),
sequence INTEGER,
seas_seq TEXT,
season TEXT
REFERENCES season_label (season),
num_days REAL NOT NULL,
notes TEXT,
PRIMARY KEY (period, sequence, seas_seq, season),
CHECK (num_days > 0)
);
CREATE TABLE IF NOT EXISTS time_period_type
(
label TEXT
Expand Down
23 changes: 0 additions & 23 deletions temoa/db_schema/temoa_schema_v4.sql
Original file line number Diff line number Diff line change
Expand Up @@ -959,29 +959,6 @@ CREATE TABLE IF NOT EXISTS time_period
flag TEXT
REFERENCES time_period_type (label)
);
CREATE TABLE IF NOT EXISTS time_season_all
(
period INTEGER
REFERENCES time_period (period),
sequence INTEGER,
season TEXT
REFERENCES season_label (season),
notes TEXT,
PRIMARY KEY (period, sequence, season)
);
CREATE TABLE IF NOT EXISTS time_season_to_sequential
(
period INTEGER
REFERENCES time_period (period),
sequence INTEGER,
seas_seq TEXT,
season TEXT
REFERENCES season_label (season),
num_days REAL NOT NULL,
notes TEXT,
PRIMARY KEY (period, sequence, seas_seq, season),
CHECK (num_days > 0)
);
CREATE TABLE IF NOT EXISTS time_period_type
(
label TEXT
Expand Down
4 changes: 2 additions & 2 deletions temoa/utilities/db_migration_v3_1_to_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
# ---------- Mapping configuration ----------
CUSTOM_MAP: dict[str, str] = {
'TimeSeason': 'time_season',
'time_season': 'time_season_all',
'time_season': 'time_season',
'TimeSeasonSequential': 'time_season_sequential',
'time_season_sequential': 'time_season_to_sequential',
'time_season_sequential': 'time_season_sequential',
'TimeNext': 'time_manual',
'CommodityDStreamProcess': 'commodity_down_stream_process',
'commodityUStreamProcess': 'commodity_up_stream_process',
Expand Down
8 changes: 4 additions & 4 deletions temoa/utilities/sql_migration_v3_1_to_v4.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
"""
sql_migration_v_3_1_to_v4.py (Robust version)
sql_migration_v_3_1_to_v4.py

Converts a v3.1 SQL dump (text) into a valid v4 SQL dump.
This script:
Expand Down Expand Up @@ -28,14 +28,14 @@
# ------------------ Mapping configuration (mirror sqlite migrator) ------------------
CUSTOM_MAP: dict[str, str] = {
'TimeSeason': 'time_season',
'time_season': 'time_season_all', # exact-only: only exact old token -> ..._all
'time_season': 'time_season',
'TimeSeasonSequential': 'time_season_sequential',
'time_season_sequential': 'time_season_to_sequential', # exact-only
'time_season_sequential': 'time_season_sequential',
'TimeNext': 'time_manual',
'CommodityDStreamProcess': 'commodity_down_stream_process',
'commodityUStreamProcess': 'commodity_up_stream_process',
'SegFrac': 'segment_fraction',
'segfrac': 'segment_fraction', # canonical column name for column 'segfrac'
'segfrac': 'segment_fraction',
'MetaDataReal': 'metadata_real',
'MetaData': 'metadata',
'Myopicefficiency': 'myopic_efficiency',
Expand Down
25 changes: 2 additions & 23 deletions tests/testing_data/annualised_demand.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1050,16 +1050,7 @@ CREATE TABLE time_season
PRIMARY KEY (period, sequence, season)
);
INSERT INTO "time_season" VALUES(2000,0,'S1',NULL);
CREATE TABLE time_season_all
(
period INTEGER
REFERENCES time_period (period),
sequence INTEGER,
season TEXT
REFERENCES season_label (season),
notes TEXT,
PRIMARY KEY (period, sequence, season)
);

CREATE TABLE time_season_sequential
(
period INTEGER REFERENCES time_period (period),
Expand All @@ -1071,19 +1062,7 @@ CREATE TABLE time_season_sequential
PRIMARY KEY (period, sequence, seas_seq, season),
CHECK (num_days > 0)
);
CREATE TABLE time_season_to_sequential
(
period INTEGER
REFERENCES time_period (period),
sequence INTEGER,
seas_seq TEXT,
season TEXT
REFERENCES season_label (season),
num_days REAL NOT NULL,
notes TEXT,
PRIMARY KEY (period, sequence, seas_seq, season),
CHECK (num_days > 0)
);

CREATE TABLE time_segment_fraction
(
period INTEGER
Expand Down
Loading