Create DUI3Config.db file and objects table if not exists (#389)
This commit is contained in:
@@ -18,6 +18,11 @@ module SpeckleConnector3
|
||||
|
||||
# @param sketchup_model [Sketchup::Model] active model.
|
||||
def self.read_preferences(sketchup_model)
|
||||
unless File.exist?(SPECKLE_CONFIG_DB_PATH)
|
||||
File.new(SPECKLE_CONFIG_DB_PATH, "w")
|
||||
db = Sqlite3::Database.new(SPECKLE_CONFIG_DB_PATH)
|
||||
create_objects_table(db)
|
||||
end
|
||||
db = Sqlite3::Database.new(SPECKLE_CONFIG_DB_PATH)
|
||||
user_preferences = validate_user_preferences(db)
|
||||
model_preferences = validate_model_preferences(sketchup_model)
|
||||
@@ -29,6 +34,17 @@ module SpeckleConnector3
|
||||
)
|
||||
end
|
||||
|
||||
# Creates the 'objects' table in the database if it doesn't already exist.
|
||||
# @param db [Sqlite3::Database] the SQLite3 database instance.
|
||||
def self.create_objects_table(db)
|
||||
db.exec <<-SQL
|
||||
CREATE TABLE IF NOT EXISTS objects (
|
||||
hash TEXT PRIMARY KEY,
|
||||
content TEXT
|
||||
);
|
||||
SQL
|
||||
end
|
||||
|
||||
# Whether row data is complete with preference or not.
|
||||
# It is useful for backward compatibility, when we add new preferences it should be reset when user initialize it.
|
||||
def self.data_complete?(row_data)
|
||||
|
||||
Reference in New Issue
Block a user