From 77d78b9023106cedd81703a1c6735e9109f631bb Mon Sep 17 00:00:00 2001 From: hellekin Date: Tue, 6 Oct 2020 16:17:44 +0200 Subject: Add Resource model Resources will be stored as JSON, in the (GeoJSON) :feature column. They are assigned an UUID upon creation if they don't comme with one. They belong to an Agent. --- db/migrate/20201006140511_create_resources.rb | 13 +++++++++++++ db/schema.rb | 10 +++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20201006140511_create_resources.rb (limited to 'db') diff --git a/db/migrate/20201006140511_create_resources.rb b/db/migrate/20201006140511_create_resources.rb new file mode 100644 index 0000000..761d5bc --- /dev/null +++ b/db/migrate/20201006140511_create_resources.rb @@ -0,0 +1,13 @@ +class CreateResources < ActiveRecord::Migration[6.0] + def change + create_table :resources do |t| + t.uuid :uuid + t.jsonb :feature + t.references :agent, null: false, foreign_key: true + + t.timestamps + end + add_index :resources, [:uuid], unique: true + add_index :resources, [:agent_id] + end +end diff --git a/db/schema.rb b/db/schema.rb index ef4f4cd..8433cd9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2020_10_05_155004) do +ActiveRecord::Schema.define(version: 2020_10_06_140511) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -34,6 +34,14 @@ ActiveRecord::Schema.define(version: 2020_10_05_155004) do t.index ["uuid"], name: "index_agents_on_uuid", unique: true end + create_table "resources", force: :cascade do |t| + t.uuid "uuid" + t.jsonb "feature" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + t.index ["uuid"], name: "index_resources_on_uuid", unique: true + end + create_table "users", force: :cascade do |t| t.string "name" t.string "username" -- cgit v1.2.3