diff options
author | dusoleil <howcansocksbereal@gmail.com> | 2022-08-29 06:32:29 -0400 |
---|---|---|
committer | dusoleil <howcansocksbereal@gmail.com> | 2022-08-29 06:32:29 -0400 |
commit | 1907c3b9e2223005697fca88abc051c72d67531d (patch) | |
tree | 699fba3f1296c2221c97fe1fdfb6548dbdabddb1 /data_model/db_update.gd | |
parent | b32d06e251dd528ddde00e78792f3e0e0e0bcfb3 (diff) | |
download | Planner-master.tar.gz Planner-master.zip |
Diffstat (limited to 'data_model/db_update.gd')
-rw-r--r-- | data_model/db_update.gd | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/data_model/db_update.gd b/data_model/db_update.gd new file mode 100644 index 0000000..595f1bc --- /dev/null +++ b/data_model/db_update.gd @@ -0,0 +1,23 @@ +class_name db_update + +static func update(DBMS): + while true: + var version = get_version(DBMS) + match version: + [0,1,0]: break + _: exec_sql_file(DBMS, "res://data_model/schema.sql") + #insert_test_data(DBMS) + +static func get_version(DBMS): + var version = DBMS.query("select * from Version", []) + return [0,0,0] if version.size() == 0 else [version[0]['major'],version[0]['minor'],version[0]['patch']] + +static func exec_sql_file(DBMS, file): + var f = File.new() + f.open(file, File.READ) + var sql = f.get_as_text() + f.close() + DBMS.query(sql,[]) + +static func insert_test_data(DBMS): + exec_sql_file(DBMS, "res://data_model/test_data.sql") |