diff --git a/spec/migration/Dockerfile b/spec/migration/Dockerfile index a8e93eb..8eaa281 100644 --- a/spec/migration/Dockerfile +++ b/spec/migration/Dockerfile @@ -4,6 +4,9 @@ WORKDIR /app COPY . /app +RUN git clone https://github.com/PlaceOS/models +RUN mv ./models/migration/db ./db + ENV PATH /app/bin:$PATH RUN shards build diff --git a/spec/migration/db/migrations/20221103181928_add_api_key_table.sql b/spec/migration/db/migrations/20221103181928_add_api_key_table.sql deleted file mode 100644 index 00b5209..0000000 --- a/spec/migration/db/migrations/20221103181928_add_api_key_table.sql +++ /dev/null @@ -1,25 +0,0 @@ --- +micrate Up --- SQL in section 'Up' is executed when this migration is applied - --- Table for model PlaceOS::Model::ApiKey -CREATE TABLE IF NOT EXISTS "api_key"( - created_at TIMESTAMPTZ NOT NULL, - updated_at TIMESTAMPTZ NOT NULL, - name TEXT NOT NULL, - description TEXT NOT NULL, - scopes JSONB NOT NULL, - permissions INTEGER, - secret TEXT NOT NULL, - user_id TEXT, - authority_id TEXT, - id TEXT NOT NULL PRIMARY KEY -); - -CREATE INDEX IF NOT EXISTS api_key_user_id_index ON "api_key" USING BTREE (user_id); -CREATE INDEX IF NOT EXISTS api_key_authority_id_index ON "api_key" USING BTREE (authority_id); -CREATE INDEX IF NOT EXISTS api_key_name_index ON "api_key" USING BTREE (name); - --- +micrate Down --- SQL section 'Down' is executed when this migration is rolled back - -DROP TABLE IF EXISTS "api_key" \ No newline at end of file diff --git a/spec/migration/db/migrations/20221103181946_add_asset_table.sql b/spec/migration/db/migrations/20221103181946_add_asset_table.sql deleted file mode 100644 index b8149cc..0000000 --- a/spec/migration/db/migrations/20221103181946_add_asset_table.sql +++ /dev/null @@ -1,30 +0,0 @@ --- +micrate Up --- SQL in section 'Up' is executed when this migration is applied - --- Table for model PlaceOS::Model::Asset -CREATE TABLE IF NOT EXISTS "asset"( - created_at TIMESTAMPTZ NOT NULL, - updated_at TIMESTAMPTZ NOT NULL, - name TEXT NOT NULL, - category TEXT NOT NULL, - description TEXT NOT NULL, - purchase_date TIMESTAMPTZ NOT NULL, - good_until_date TIMESTAMPTZ, - identifier TEXT, - brand TEXT NOT NULL, - purchase_price INTEGER NOT NULL, - images TEXT[] NOT NULL, - invoice TEXT, - quantity INTEGER NOT NULL, - in_use INTEGER NOT NULL, - other_data JSONB NOT NULL, - parent_id TEXT, - id TEXT NOT NULL PRIMARY KEY -); - -CREATE INDEX IF NOT EXISTS asset_parent_id_index ON "asset" USING BTREE (parent_id); - --- +micrate Down --- SQL section 'Down' is executed when this migration is rolled back - -DROP TABLE IF EXISTS "asset" \ No newline at end of file diff --git a/spec/migration/db/migrations/20221103181954_add_repo_table.sql b/spec/migration/db/migrations/20221103181954_add_repo_table.sql deleted file mode 100644 index 203dd8b..0000000 --- a/spec/migration/db/migrations/20221103181954_add_repo_table.sql +++ /dev/null @@ -1,27 +0,0 @@ --- +micrate Up --- SQL in section 'Up' is executed when this migration is applied - --- Table for model PlaceOS::Model::Repository -CREATE TABLE IF NOT EXISTS "repo"( - created_at TIMESTAMPTZ NOT NULL, - updated_at TIMESTAMPTZ NOT NULL, - name TEXT NOT NULL, - description TEXT NOT NULL, - folder_name TEXT NOT NULL, - uri TEXT NOT NULL, - commit_hash TEXT NOT NULL, - branch TEXT NOT NULL, - deployed_commit_hash TEXT, - release BOOLEAN NOT NULL, - username TEXT, - password TEXT, - repo_type INTEGER NOT NULL, - id TEXT NOT NULL PRIMARY KEY -); - -CREATE INDEX IF NOT EXISTS repo_folder_name_index ON "repo" USING BTREE (folder_name); - --- +micrate Down --- SQL section 'Down' is executed when this migration is rolled back - -DROP TABLE IF EXISTS "repo" \ No newline at end of file diff --git a/spec/migration/db/migrations/20221103182003_add_driver_table.sql b/spec/migration/db/migrations/20221103182003_add_driver_table.sql deleted file mode 100644 index efc944f..0000000 --- a/spec/migration/db/migrations/20221103182003_add_driver_table.sql +++ /dev/null @@ -1,28 +0,0 @@ --- +micrate Up --- SQL in section 'Up' is executed when this migration is applied - --- Table for model PlaceOS::Model::Driver -CREATE TABLE IF NOT EXISTS "driver"( - created_at TIMESTAMPTZ NOT NULL, - updated_at TIMESTAMPTZ NOT NULL, - name TEXT NOT NULL, - description TEXT NOT NULL, - json_schema JSONB NOT NULL, - default_uri TEXT, - default_port INTEGER, - role INTEGER NOT NULL, - file_name TEXT NOT NULL, - commit TEXT NOT NULL, - compilation_output TEXT, - module_name TEXT NOT NULL, - ignore_connected BOOLEAN NOT NULL, - repository_id TEXT NOT NULL, - id TEXT NOT NULL PRIMARY KEY -); - -CREATE INDEX IF NOT EXISTS driver_repository_id_index ON "driver" USING BTREE (repository_id); - --- +micrate Down --- SQL section 'Down' is executed when this migration is rolled back - -DROP TABLE IF EXISTS "driver" \ No newline at end of file diff --git a/spec/migration/db/migrations/20221103182008_add_edge_table.sql b/spec/migration/db/migrations/20221103182008_add_edge_table.sql deleted file mode 100644 index 22222c6..0000000 --- a/spec/migration/db/migrations/20221103182008_add_edge_table.sql +++ /dev/null @@ -1,21 +0,0 @@ --- +micrate Up --- SQL in section 'Up' is executed when this migration is applied - --- Table for model PlaceOS::Model::Edge -CREATE TABLE IF NOT EXISTS "edge"( - created_at TIMESTAMPTZ NOT NULL, - updated_at TIMESTAMPTZ NOT NULL, - name TEXT NOT NULL, - description TEXT NOT NULL, - api_key_id TEXT NOT NULL, - user_id TEXT NOT NULL, - id TEXT NOT NULL PRIMARY KEY -); - -CREATE INDEX IF NOT EXISTS edge_api_key_id_index ON "edge" USING BTREE (api_key_id); -CREATE INDEX IF NOT EXISTS edge_name_index ON "edge" USING BTREE (name); - --- +micrate Down --- SQL section 'Down' is executed when this migration is rolled back - -DROP TABLE IF EXISTS "edge" \ No newline at end of file diff --git a/spec/migration/db/migrations/20221103182015_add_mod_table.sql b/spec/migration/db/migrations/20221103182015_add_mod_table.sql deleted file mode 100644 index 3c72dcc..0000000 --- a/spec/migration/db/migrations/20221103182015_add_mod_table.sql +++ /dev/null @@ -1,35 +0,0 @@ --- +micrate Up --- SQL in section 'Up' is executed when this migration is applied - --- Table for model PlaceOS::Model::Module -CREATE TABLE IF NOT EXISTS "mod"( - created_at TIMESTAMPTZ NOT NULL, - updated_at TIMESTAMPTZ NOT NULL, - ip TEXT NOT NULL, - port INTEGER NOT NULL, - tls BOOLEAN NOT NULL, - udp BOOLEAN NOT NULL, - makebreak BOOLEAN NOT NULL, - uri TEXT NOT NULL, - name TEXT NOT NULL, - custom_name TEXT, - role INTEGER NOT NULL, - connected BOOLEAN NOT NULL, - running BOOLEAN NOT NULL, - notes TEXT NOT NULL, - ignore_connected BOOLEAN NOT NULL, - ignore_startstop BOOLEAN NOT NULL, - control_system_id TEXT, - driver_id TEXT NOT NULL, - edge_id TEXT, - id TEXT NOT NULL PRIMARY KEY -); - -CREATE INDEX IF NOT EXISTS mod_control_system_id_index ON "mod" USING BTREE (control_system_id); -CREATE INDEX IF NOT EXISTS mod_driver_id_index ON "mod" USING BTREE (driver_id); -CREATE INDEX IF NOT EXISTS mod_edge_id_index ON "mod" USING BTREE (edge_id); - --- +micrate Down --- SQL section 'Down' is executed when this migration is rolled back - -DROP TABLE IF EXISTS "mod" \ No newline at end of file diff --git a/spec/migration/db/migrations/20221103182025_add_zone_table.sql b/spec/migration/db/migrations/20221103182025_add_zone_table.sql deleted file mode 100644 index e7faa2c..0000000 --- a/spec/migration/db/migrations/20221103182025_add_zone_table.sql +++ /dev/null @@ -1,31 +0,0 @@ --- +micrate Up --- SQL in section 'Up' is executed when this migration is applied - --- Table for model PlaceOS::Model::Zone -CREATE TABLE IF NOT EXISTS "zone"( - created_at TIMESTAMPTZ NOT NULL, - updated_at TIMESTAMPTZ NOT NULL, - name TEXT NOT NULL, - description TEXT NOT NULL, - tags TEXT[] NOT NULL, - location TEXT, - display_name TEXT, - code TEXT, - type TEXT, - count INTEGER NOT NULL, - capacity INTEGER NOT NULL, - map_id TEXT, - timezone TEXT, - triggers TEXT[] NOT NULL, - images TEXT[] NOT NULL, - parent_id TEXT, - id TEXT NOT NULL PRIMARY KEY -); - -CREATE INDEX IF NOT EXISTS zone_parent_id_index ON "zone" USING BTREE (parent_id); -CREATE INDEX IF NOT EXISTS zone_name_index ON "zone" USING BTREE (name); - --- +micrate Down --- SQL section 'Down' is executed when this migration is rolled back - -DROP TABLE IF EXISTS "zone" \ No newline at end of file diff --git a/spec/migration/db/migrations/20221103182030_add_sets_table.sql b/spec/migration/db/migrations/20221103182030_add_sets_table.sql deleted file mode 100644 index 494a0fa..0000000 --- a/spec/migration/db/migrations/20221103182030_add_sets_table.sql +++ /dev/null @@ -1,24 +0,0 @@ --- +micrate Up --- SQL in section 'Up' is executed when this migration is applied - --- Table for model PlaceOS::Model::Settings -CREATE TABLE IF NOT EXISTS "sets"( - created_at TIMESTAMPTZ NOT NULL, - updated_at TIMESTAMPTZ NOT NULL, - modified_by_id TEXT, - settings_id TEXT, - encryption_level INTEGER NOT NULL, - settings_string TEXT NOT NULL, - keys TEXT[] NOT NULL, - parent_type INTEGER NOT NULL, - parent_id TEXT, - id TEXT NOT NULL PRIMARY KEY -); - -CREATE INDEX IF NOT EXISTS sets_settings_id_index ON "sets" USING BTREE (settings_id); -CREATE INDEX IF NOT EXISTS sets_parent_id_index ON "sets" USING BTREE (parent_id); - --- +micrate Down --- SQL section 'Down' is executed when this migration is rolled back - -DROP TABLE IF EXISTS "sets" \ No newline at end of file diff --git a/spec/migration/db/migrations/20221103182036_add_sys_table.sql b/spec/migration/db/migrations/20221103182036_add_sys_table.sql deleted file mode 100644 index 614d742..0000000 --- a/spec/migration/db/migrations/20221103182036_add_sys_table.sql +++ /dev/null @@ -1,34 +0,0 @@ --- +micrate Up --- SQL in section 'Up' is executed when this migration is applied - --- Table for model PlaceOS::Model::ControlSystem -CREATE TABLE IF NOT EXISTS "sys"( - created_at TIMESTAMPTZ NOT NULL, - updated_at TIMESTAMPTZ NOT NULL, - name TEXT NOT NULL, - description TEXT NOT NULL, - features TEXT[] NOT NULL, - email TEXT, - bookable BOOLEAN NOT NULL, - display_name TEXT, - code TEXT, - type TEXT, - capacity INTEGER NOT NULL, - map_id TEXT, - images TEXT[] NOT NULL, - timezone TEXT, - support_url TEXT NOT NULL, - version INTEGER NOT NULL, - installed_ui_devices INTEGER NOT NULL, - zones TEXT[] NOT NULL, - modules TEXT[] NOT NULL, - id TEXT NOT NULL PRIMARY KEY -); - -CREATE INDEX IF NOT EXISTS sys_email_index ON "sys" USING BTREE (email); -CREATE INDEX IF NOT EXISTS sys_name_index ON "sys" USING BTREE (name); - --- +micrate Down --- SQL section 'Down' is executed when this migration is rolled back - -DROP TABLE IF EXISTS "sys" \ No newline at end of file diff --git a/spec/migration/db/migrations/20221103182045_add_metadata_table.sql b/spec/migration/db/migrations/20221103182045_add_metadata_table.sql deleted file mode 100644 index 5001e52..0000000 --- a/spec/migration/db/migrations/20221103182045_add_metadata_table.sql +++ /dev/null @@ -1,27 +0,0 @@ --- +micrate Up --- SQL in section 'Up' is executed when this migration is applied - --- Table for model PlaceOS::Model::Metadata -CREATE TABLE IF NOT EXISTS "metadata"( - created_at TIMESTAMPTZ NOT NULL, - updated_at TIMESTAMPTZ NOT NULL, - modified_by_id TEXT, - metadata_id TEXT, - name TEXT NOT NULL, - description TEXT NOT NULL, - details JSONB NOT NULL, - editors TEXT[] NOT NULL, - parent_id TEXT, - schema_id TEXT, - id TEXT NOT NULL PRIMARY KEY -); - -CREATE INDEX IF NOT EXISTS metadata_metadata_id_index ON "metadata" USING BTREE (metadata_id); -CREATE INDEX IF NOT EXISTS metadata_parent_id_index ON "metadata" USING BTREE (parent_id); -CREATE INDEX IF NOT EXISTS metadata_name_index ON "metadata" USING BTREE (name); -CREATE INDEX IF NOT EXISTS metadata_schema_id_index ON "metadata" USING BTREE (schema_id); - --- +micrate Down --- SQL section 'Down' is executed when this migration is rolled back - -DROP TABLE IF EXISTS "metadata" \ No newline at end of file diff --git a/spec/migration/db/migrations/20221103182052_add_user_table.sql b/spec/migration/db/migrations/20221103182052_add_user_table.sql deleted file mode 100644 index aacf0bd..0000000 --- a/spec/migration/db/migrations/20221103182052_add_user_table.sql +++ /dev/null @@ -1,48 +0,0 @@ --- +micrate Up --- SQL in section 'Up' is executed when this migration is applied - --- Table for model PlaceOS::Model::User -CREATE TABLE IF NOT EXISTS "user"( - created_at TIMESTAMPTZ NOT NULL, - updated_at TIMESTAMPTZ NOT NULL, - name TEXT NOT NULL, - nickname TEXT NOT NULL, - email TEXT NOT NULL, - phone TEXT NOT NULL, - country TEXT NOT NULL, - image TEXT NOT NULL, - ui_theme TEXT NOT NULL, - misc TEXT NOT NULL, - login_name TEXT, - staff_id TEXT, - first_name TEXT, - last_name TEXT, - building TEXT, - department TEXT, - preferred_language TEXT, - password_digest TEXT, - email_digest TEXT, - card_number TEXT, - deleted BOOLEAN NOT NULL, - groups TEXT[] NOT NULL, - access_token TEXT, - refresh_token TEXT, - expires_at BIGINT, - expires BOOLEAN NOT NULL, - password TEXT, - sys_admin BOOLEAN NOT NULL, - support BOOLEAN NOT NULL, - authority_id TEXT, - id TEXT NOT NULL PRIMARY KEY -); - -CREATE INDEX IF NOT EXISTS user_authority_id_index ON "user" USING BTREE (authority_id); -CREATE INDEX IF NOT EXISTS user_email_digest_index ON "user" USING BTREE (email_digest); -CREATE INDEX IF NOT EXISTS user_login_name_index ON "user" USING BTREE (login_name); -CREATE INDEX IF NOT EXISTS user_staff_id_index ON "user" USING BTREE (staff_id); -CREATE INDEX IF NOT EXISTS user_sys_admin_index ON "user" USING BTREE (sys_admin); - --- +micrate Down --- SQL section 'Down' is executed when this migration is rolled back - -DROP TABLE IF EXISTS "user" \ No newline at end of file diff --git a/spec/migration/db/migrations/20221103182102_add_ldap_strat_table.sql b/spec/migration/db/migrations/20221103182102_add_ldap_strat_table.sql deleted file mode 100644 index 358f7d6..0000000 --- a/spec/migration/db/migrations/20221103182102_add_ldap_strat_table.sql +++ /dev/null @@ -1,26 +0,0 @@ --- +micrate Up --- SQL in section 'Up' is executed when this migration is applied - --- Table for model PlaceOS::Model::LdapAuthentication -CREATE TABLE IF NOT EXISTS "ldap_strat"( - created_at TIMESTAMPTZ NOT NULL, - updated_at TIMESTAMPTZ NOT NULL, - name TEXT NOT NULL, - port INTEGER NOT NULL, - auth_method TEXT NOT NULL, - uid TEXT NOT NULL, - host TEXT NOT NULL, - base TEXT NOT NULL, - bind_dn TEXT, - password TEXT, - filter TEXT, - authority_id TEXT, - id TEXT NOT NULL PRIMARY KEY -); - -CREATE INDEX IF NOT EXISTS ldap_strat_authority_id_index ON "ldap_strat" USING BTREE (authority_id); - --- +micrate Down --- SQL section 'Down' is executed when this migration is rolled back - -DROP TABLE IF EXISTS "ldap_strat" \ No newline at end of file diff --git a/spec/migration/db/migrations/20221103182109_add_oauth_strat_table.sql b/spec/migration/db/migrations/20221103182109_add_oauth_strat_table.sql deleted file mode 100644 index f9a16bc..0000000 --- a/spec/migration/db/migrations/20221103182109_add_oauth_strat_table.sql +++ /dev/null @@ -1,30 +0,0 @@ --- +micrate Up --- SQL in section 'Up' is executed when this migration is applied - --- Table for model PlaceOS::Model::OAuthAuthentication -CREATE TABLE IF NOT EXISTS "oauth_strat"( - created_at TIMESTAMPTZ NOT NULL, - updated_at TIMESTAMPTZ NOT NULL, - name TEXT NOT NULL, - client_id TEXT NOT NULL, - client_secret TEXT NOT NULL, - info_mappings JSONB NOT NULL, - authorize_params JSONB NOT NULL, - ensure_matching JSONB NOT NULL, - site TEXT NOT NULL, - authorize_url TEXT NOT NULL, - token_method TEXT NOT NULL, - auth_scheme TEXT NOT NULL, - token_url TEXT NOT NULL, - scope TEXT NOT NULL, - raw_info_url TEXT, - authority_id TEXT, - id TEXT NOT NULL PRIMARY KEY -); - -CREATE INDEX IF NOT EXISTS oauth_strat_authority_id_index ON "oauth_strat" USING BTREE (authority_id); - --- +micrate Down --- SQL section 'Down' is executed when this migration is rolled back - -DROP TABLE IF EXISTS "oauth_strat" \ No newline at end of file diff --git a/spec/migration/db/migrations/20221103182121_add_adfs_strat_table.sql b/spec/migration/db/migrations/20221103182121_add_adfs_strat_table.sql deleted file mode 100644 index 835bc23..0000000 --- a/spec/migration/db/migrations/20221103182121_add_adfs_strat_table.sql +++ /dev/null @@ -1,31 +0,0 @@ --- +micrate Up --- SQL in section 'Up' is executed when this migration is applied - --- Table for model PlaceOS::Model::SamlAuthentication -CREATE TABLE IF NOT EXISTS "adfs_strat"( - created_at TIMESTAMPTZ NOT NULL, - updated_at TIMESTAMPTZ NOT NULL, - name TEXT NOT NULL, - issuer TEXT NOT NULL, - idp_sso_target_url_runtime_params JSONB NOT NULL, - name_identifier_format TEXT NOT NULL, - uid_attribute TEXT, - assertion_consumer_service_url TEXT NOT NULL, - idp_sso_target_url TEXT NOT NULL, - idp_cert TEXT, - idp_cert_fingerprint TEXT, - attribute_service_name TEXT, - attribute_statements JSONB NOT NULL, - request_attributes JSONB NOT NULL, - idp_slo_target_url TEXT, - slo_default_relay_state TEXT, - authority_id TEXT, - id TEXT NOT NULL PRIMARY KEY -); - -CREATE INDEX IF NOT EXISTS adfs_strat_authority_id_index ON "adfs_strat" USING BTREE (authority_id); - --- +micrate Down --- SQL section 'Down' is executed when this migration is rolled back - -DROP TABLE IF EXISTS "adfs_strat" \ No newline at end of file diff --git a/spec/migration/db/migrations/20221103182131_add_authority_table.sql b/spec/migration/db/migrations/20221103182131_add_authority_table.sql deleted file mode 100644 index 8ea21a7..0000000 --- a/spec/migration/db/migrations/20221103182131_add_authority_table.sql +++ /dev/null @@ -1,23 +0,0 @@ --- +micrate Up --- SQL in section 'Up' is executed when this migration is applied - --- Table for model PlaceOS::Model::Authority -CREATE TABLE IF NOT EXISTS "authority"( - created_at TIMESTAMPTZ NOT NULL, - updated_at TIMESTAMPTZ NOT NULL, - name TEXT NOT NULL, - description TEXT NOT NULL, - domain TEXT NOT NULL, - login_url TEXT NOT NULL, - logout_url TEXT NOT NULL, - internals JSONB NOT NULL, - config JSONB NOT NULL, - id TEXT NOT NULL PRIMARY KEY -); - -CREATE INDEX IF NOT EXISTS authority_domain_index ON "authority" USING BTREE (domain); - --- +micrate Down --- SQL section 'Down' is executed when this migration is rolled back - -DROP TABLE IF EXISTS "authority" \ No newline at end of file diff --git a/spec/migration/db/migrations/20221103182136_add_ass_table.sql b/spec/migration/db/migrations/20221103182136_add_ass_table.sql deleted file mode 100644 index 5370e30..0000000 --- a/spec/migration/db/migrations/20221103182136_add_ass_table.sql +++ /dev/null @@ -1,26 +0,0 @@ --- +micrate Up --- SQL in section 'Up' is executed when this migration is applied - --- Table for model PlaceOS::Model::AssetInstance -CREATE TABLE IF NOT EXISTS "ass"( - created_at TIMESTAMPTZ NOT NULL, - updated_at TIMESTAMPTZ NOT NULL, - name TEXT NOT NULL, - tracking INTEGER NOT NULL, - approval BOOLEAN NOT NULL, - asset_id TEXT, - requester_id TEXT, - zone_id TEXT, - usage_start TIMESTAMPTZ NOT NULL, - usage_end TIMESTAMPTZ NOT NULL, - id TEXT NOT NULL PRIMARY KEY -); - -CREATE INDEX IF NOT EXISTS ass_asset_id_index ON "ass" USING BTREE (asset_id); -CREATE INDEX IF NOT EXISTS ass_zone_id_index ON "ass" USING BTREE (zone_id); -CREATE INDEX IF NOT EXISTS ass_requester_id_index ON "ass" USING BTREE (requester_id); - --- +micrate Down --- SQL section 'Down' is executed when this migration is rolled back - -DROP TABLE IF EXISTS "ass" \ No newline at end of file diff --git a/spec/migration/db/migrations/20221103182144_add_broker_table.sql b/spec/migration/db/migrations/20221103182144_add_broker_table.sql deleted file mode 100644 index 5aceb7b..0000000 --- a/spec/migration/db/migrations/20221103182144_add_broker_table.sql +++ /dev/null @@ -1,27 +0,0 @@ --- +micrate Up --- SQL in section 'Up' is executed when this migration is applied - --- Table for model PlaceOS::Model::Broker -CREATE TABLE IF NOT EXISTS "broker"( - created_at TIMESTAMPTZ NOT NULL, - updated_at TIMESTAMPTZ NOT NULL, - auth_type INTEGER NOT NULL, - name TEXT NOT NULL, - description TEXT NOT NULL, - host TEXT NOT NULL, - port INTEGER NOT NULL, - tls BOOLEAN NOT NULL, - username TEXT, - password TEXT, - certificate TEXT, - secret TEXT NOT NULL, - filters TEXT[] NOT NULL, - id TEXT NOT NULL PRIMARY KEY -); - -CREATE INDEX IF NOT EXISTS broker_name_index ON "broker" USING BTREE (name); - --- +micrate Down --- SQL section 'Down' is executed when this migration is rolled back - -DROP TABLE IF EXISTS "broker" \ No newline at end of file diff --git a/spec/migration/db/migrations/20221103182153_add_doorkeeper_app_table.sql b/spec/migration/db/migrations/20221103182153_add_doorkeeper_app_table.sql deleted file mode 100644 index 46554f1..0000000 --- a/spec/migration/db/migrations/20221103182153_add_doorkeeper_app_table.sql +++ /dev/null @@ -1,26 +0,0 @@ --- +micrate Up --- SQL in section 'Up' is executed when this migration is applied - --- Table for model PlaceOS::Model::DoorkeeperApplication -CREATE TABLE IF NOT EXISTS "doorkeeper_app"( - created_at TIMESTAMPTZ NOT NULL, - updated_at TIMESTAMPTZ NOT NULL, - name TEXT NOT NULL, - secret TEXT NOT NULL, - scopes TEXT NOT NULL, - owner_id TEXT NOT NULL, - redirect_uri TEXT NOT NULL, - skip_authorization BOOLEAN NOT NULL, - confidential BOOLEAN NOT NULL, - revoked_at TIMESTAMPTZ, - uid TEXT NOT NULL, - id TEXT NOT NULL PRIMARY KEY -); - -CREATE INDEX IF NOT EXISTS doorkeeper_app_uid_index ON "doorkeeper_app" USING BTREE (uid); -CREATE INDEX IF NOT EXISTS doorkeeper_app_redirect_uri_index ON "doorkeeper_app" USING BTREE (redirect_uri); -CREATE INDEX IF NOT EXISTS doorkeeper_app_name_index ON "doorkeeper_app" USING BTREE (name); - --- +micrate Down --- SQL section 'Down' is executed when this migration is rolled back -DROP TABLE IF EXISTS "doorkeeper_app" \ No newline at end of file diff --git a/spec/migration/db/migrations/20221103182204_add_json_schema_table.sql b/spec/migration/db/migrations/20221103182204_add_json_schema_table.sql deleted file mode 100644 index 9008f33..0000000 --- a/spec/migration/db/migrations/20221103182204_add_json_schema_table.sql +++ /dev/null @@ -1,17 +0,0 @@ --- +micrate Up --- SQL in section 'Up' is executed when this migration is applied - --- Table for model PlaceOS::Model::JsonSchema -CREATE TABLE IF NOT EXISTS "json_schema"( - created_at TIMESTAMPTZ NOT NULL, - updated_at TIMESTAMPTZ NOT NULL, - name TEXT NOT NULL, - description TEXT NOT NULL, - schema JSONB NOT NULL, - id TEXT NOT NULL PRIMARY KEY -); - - --- +micrate Down --- SQL section 'Down' is executed when this migration is rolled back -DROP TABLE IF EXISTS "json_schema" \ No newline at end of file diff --git a/spec/migration/db/migrations/20221103182211_add_trigger_table.sql b/spec/migration/db/migrations/20221103182211_add_trigger_table.sql deleted file mode 100644 index 444686d..0000000 --- a/spec/migration/db/migrations/20221103182211_add_trigger_table.sql +++ /dev/null @@ -1,24 +0,0 @@ --- +micrate Up --- SQL in section 'Up' is executed when this migration is applied - --- Table for model PlaceOS::Model::Trigger -CREATE TABLE IF NOT EXISTS "trigger"( - created_at TIMESTAMPTZ NOT NULL, - updated_at TIMESTAMPTZ NOT NULL, - name TEXT NOT NULL, - description TEXT NOT NULL, - actions JSONB NOT NULL, - conditions JSONB NOT NULL, - debounce_period INTEGER NOT NULL, - important BOOLEAN NOT NULL, - enable_webhook BOOLEAN NOT NULL, - supported_methods TEXT[] NOT NULL, - control_system_id TEXT, - id TEXT NOT NULL PRIMARY KEY -); - -CREATE INDEX IF NOT EXISTS trigger_control_system_id_index ON "trigger" USING BTREE (control_system_id); - --- +micrate Down --- SQL section 'Down' is executed when this migration is rolled back -DROP TABLE IF EXISTS "trigger" \ No newline at end of file diff --git a/spec/migration/db/migrations/20221103182218_add_trig_table.sql b/spec/migration/db/migrations/20221103182218_add_trig_table.sql deleted file mode 100644 index 96123bc..0000000 --- a/spec/migration/db/migrations/20221103182218_add_trig_table.sql +++ /dev/null @@ -1,25 +0,0 @@ --- +micrate Up --- SQL in section 'Up' is executed when this migration is applied --- Table for model PlaceOS::Model::TriggerInstance -CREATE TABLE IF NOT EXISTS "trig"( - created_at TIMESTAMPTZ NOT NULL, - updated_at TIMESTAMPTZ NOT NULL, - enabled BOOLEAN NOT NULL, - triggered BOOLEAN NOT NULL, - important BOOLEAN NOT NULL, - exec_enabled BOOLEAN NOT NULL, - webhook_secret TEXT NOT NULL, - trigger_count INTEGER NOT NULL, - control_system_id TEXT, - trigger_id TEXT, - zone_id TEXT, - id TEXT NOT NULL PRIMARY KEY -); - -CREATE INDEX IF NOT EXISTS trig_control_system_id_index ON "trig" USING BTREE (control_system_id); -CREATE INDEX IF NOT EXISTS trig_trigger_id_index ON "trig" USING BTREE (trigger_id); -CREATE INDEX IF NOT EXISTS trig_zone_id_index ON "trig" USING BTREE (zone_id); - --- +micrate Down --- SQL section 'Down' is executed when this migration is rolled back -DROP TABLE IF EXISTS "trig" \ No newline at end of file diff --git a/spec/migration/db/migrations/20221103182226_add_authentication_table.sql b/spec/migration/db/migrations/20221103182226_add_authentication_table.sql deleted file mode 100644 index a473078..0000000 --- a/spec/migration/db/migrations/20221103182226_add_authentication_table.sql +++ /dev/null @@ -1,20 +0,0 @@ --- +micrate Up --- SQL in section 'Up' is executed when this migration is applied --- Table for model PlaceOS::Model::UserAuthLookup -CREATE TABLE IF NOT EXISTS "authentication"( - created_at TIMESTAMPTZ NOT NULL, - updated_at TIMESTAMPTZ NOT NULL, - uid TEXT NOT NULL, - provider TEXT NOT NULL, - user_id TEXT, - authority_id TEXT, - id TEXT NOT NULL PRIMARY KEY -); - -CREATE INDEX IF NOT EXISTS authentication_user_id_index ON "authentication" USING BTREE (user_id); -CREATE INDEX IF NOT EXISTS authentication_authority_id_index ON "authentication" USING BTREE (authority_id); - - --- +micrate Down --- SQL section 'Down' is executed when this migration is rolled back -DROP TABLE IF EXISTS "authentication" \ No newline at end of file diff --git a/spec/migration/db/migrations/20221103182518_add_stats_table.sql b/spec/migration/db/migrations/20221103182518_add_stats_table.sql deleted file mode 100644 index 3e284d4..0000000 --- a/spec/migration/db/migrations/20221103182518_add_stats_table.sql +++ /dev/null @@ -1,19 +0,0 @@ --- +micrate Up --- SQL in section 'Up' is executed when this migration is applied - --- Table for model PlaceOS::Model::Statistics -CREATE TABLE IF NOT EXISTS "stats"( - created_at TIMESTAMPTZ NOT NULL, - updated_at TIMESTAMPTZ NOT NULL, - modules_disconnected INTEGER NOT NULL, - triggers_active INTEGER NOT NULL, - websocket_connections INTEGER NOT NULL, - fixed_connections INTEGER NOT NULL, - core_nodes_online INTEGER NOT NULL, - ttl BIGINT NOT NULL, - id TEXT NOT NULL PRIMARY KEY -); - --- +micrate Down --- SQL section 'Down' is executed when this migration is rolled back -DROP TABLE IF EXISTS "stats" \ No newline at end of file diff --git a/spec/migration/db/migrations/20230224115858_add_sys_booking_feat.sql b/spec/migration/db/migrations/20230224115858_add_sys_booking_feat.sql deleted file mode 100644 index f000b56..0000000 --- a/spec/migration/db/migrations/20230224115858_add_sys_booking_feat.sql +++ /dev/null @@ -1,9 +0,0 @@ --- +micrate Up --- SQL in section 'Up' is executed when this migration is applied - -ALTER TABLE "sys" ADD COLUMN public BOOLEAN NOT NULL DEFAULT false; - --- +micrate Down --- SQL section 'Down' is executed when this migration is rolled back - -ALTER TABLE "sys" DROP COLUMN public; diff --git a/spec/migration/db/migrations/20230314100503_alter_user_table.sql b/spec/migration/db/migrations/20230314100503_alter_user_table.sql deleted file mode 100644 index 5477adc..0000000 --- a/spec/migration/db/migrations/20230314100503_alter_user_table.sql +++ /dev/null @@ -1,18 +0,0 @@ --- +micrate Up --- SQL in section 'Up' is executed when this migration is applied - -alter table "user" alter COLUMN nickname drop NOT NULL; -alter table "user" alter COLUMN phone drop NOT NULL; -alter table "user" alter COLUMN country drop NOT NULL; -alter table "user" alter COLUMN image drop NOT NULL; -alter table "user" alter COLUMN ui_theme drop NOT NULL; -alter table "user" alter COLUMN misc drop NOT NULL; - --- +micrate Down --- SQL section 'Down' is executed when this migration is rolled back -alter table "user" alter COLUMN nickname set NOT NULL; -alter table "user" alter COLUMN phone set NOT NULL; -alter table "user" alter COLUMN country set NOT NULL; -alter table "user" alter COLUMN image set NOT NULL; -alter table "user" alter COLUMN ui_theme set NOT NULL; -alter table "user" alter COLUMN misc set NOT NULL; \ No newline at end of file diff --git a/spec/migration/shard.lock b/spec/migration/shard.lock deleted file mode 100644 index 33adf43..0000000 --- a/spec/migration/shard.lock +++ /dev/null @@ -1,14 +0,0 @@ -version: 2.0 -shards: - db: - git: https://github.com/crystal-lang/crystal-db.git - version: 0.10.1 - - micrate: - git: https://github.com/amberframework/micrate.git - version: 0.12.0 - - pg: - git: https://github.com/will/crystal-pg.git - version: 0.25.0 - diff --git a/spec/migration/shard.yml b/spec/migration/shard.yml index a19d3e9..ae3873b 100644 --- a/spec/migration/shard.yml +++ b/spec/migration/shard.yml @@ -11,5 +11,6 @@ targets: dependencies: micrate: github: amberframework/micrate + version: "0.12.0" pg: github: will/crystal-pg diff --git a/spec/spec_constants.cr b/spec/spec_constants.cr index 8c5941b..26f4815 100644 --- a/spec/spec_constants.cr +++ b/spec/spec_constants.cr @@ -61,7 +61,7 @@ module PlaceOS::Pulse "Special" => {2, 1}, "Printer" => {1, 0}, "TV" => {4, 3}, - }.transform_values { |count, running| Heartbeat::ModuleCount.new(count, running) } + }.transform_values { |(count, running)| Heartbeat::ModuleCount.new(count, running) } end class_getter metadata : Array(PlaceOS::Model::Metadata) do diff --git a/src/placeos-pulse/request/heartbeat.cr b/src/placeos-pulse/request/heartbeat.cr index 02aaf96..b1d97f3 100644 --- a/src/placeos-pulse/request/heartbeat.cr +++ b/src/placeos-pulse/request/heartbeat.cr @@ -76,7 +76,7 @@ module PlaceOS::Pulse count += 1 running += 1 if mod.running tally[mod.name] = {count, running} - end.transform_values { |count, running| ModuleCount.new(count, running) } + end.transform_values { |(count, running)| ModuleCount.new(count, running) } end def self.from_database