diff options
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20201009025353_add_default_to_resource_feature.rb | 30 | ||||
-rw-r--r-- | db/migrate/20201009061548_rename_resources_sections_to_classifications.rb | 5 | ||||
-rw-r--r-- | db/schema.rb | 15 |
3 files changed, 43 insertions, 7 deletions
diff --git a/db/migrate/20201009025353_add_default_to_resource_feature.rb b/db/migrate/20201009025353_add_default_to_resource_feature.rb new file mode 100644 index 0000000..06cad6c --- /dev/null +++ b/db/migrate/20201009025353_add_default_to_resource_feature.rb @@ -0,0 +1,30 @@ +class AddDefaultToResourceFeature < ActiveRecord::Migration[6.0] + def up + change_column_default :resources, :feature, + { + "geometry": { + "type": "Point", + "coordinates": [0,0] + }, + "properties": { + "name":"", + "description":"", + "address":"", + "postal_code":"", + "city":"", + "email":"", + "phone_number":"", + "website":"", + "categories":[], + "source":"incommon", + "entry_number":nil, + "srid":4326 + } + } + add_index :resources, :feature, using: :gin + end + def down + change_column_default :resources, :feature, nil + remove_index :resources, :feature + end +end diff --git a/db/migrate/20201009061548_rename_resources_sections_to_classifications.rb b/db/migrate/20201009061548_rename_resources_sections_to_classifications.rb new file mode 100644 index 0000000..4f7972b --- /dev/null +++ b/db/migrate/20201009061548_rename_resources_sections_to_classifications.rb @@ -0,0 +1,5 @@ +class RenameResourcesSectionsToClassifications < ActiveRecord::Migration[6.0] + def change + rename_table :resources_sections, :classifications + end +end diff --git a/db/schema.rb b/db/schema.rb index 16ba65c..0660ef9 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_08_190558) do +ActiveRecord::Schema.define(version: 2020_10_09_061548) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -50,21 +50,22 @@ ActiveRecord::Schema.define(version: 2020_10_08_190558) do t.index ["taxonomy_id"], name: "index_categories_on_taxonomy_id" end + create_table "classifications", id: false, force: :cascade do |t| + t.bigint "resource_id", null: false + t.bigint "section_id", null: false + end + create_table "resources", force: :cascade do |t| t.uuid "uuid" - t.jsonb "feature" + t.jsonb "feature", default: {"geometry"=>{"type"=>"Point", "coordinates"=>[0, 0]}, "properties"=>{"city"=>"", "name"=>"", "srid"=>4326, "email"=>"", "source"=>"incommon", "address"=>"", "website"=>"", "categories"=>[], "description"=>"", "postal_code"=>"", "entry_number"=>nil, "phone_number"=>""}} t.bigint "agent_id", null: false t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false t.index ["agent_id"], name: "index_resources_on_agent_id" + t.index ["feature"], name: "index_resources_on_feature", using: :gin t.index ["uuid"], name: "index_resources_on_uuid", unique: true end - create_table "resources_sections", id: false, force: :cascade do |t| - t.bigint "resource_id", null: false - t.bigint "section_id", null: false - end - create_table "sections", force: :cascade do |t| t.string "name", limit: 64 t.string "summary", limit: 136 |