aboutsummaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorhellekin <hellekin@cepheide.org>2020-10-06 16:17:44 +0200
committerhellekin <hellekin@cepheide.org>2020-10-06 16:21:40 +0200
commit77d78b9023106cedd81703a1c6735e9109f631bb (patch)
tree66547d568d713d1d6e01efbe80e3d10f4d9da36b /db
parent341293217aefc15a10fc81dfc1d7850f89acfb1f (diff)
downloadincommon-map-77d78b9023106cedd81703a1c6735e9109f631bb.tar.gz
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.
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20201006140511_create_resources.rb13
-rw-r--r--db/schema.rb10
2 files changed, 22 insertions, 1 deletions
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"