diff --git a/db/migrate/20170103171414_add_test_and_public_to_projects.rb b/db/migrate/20170103171414_add_test_and_public_to_projects.rb deleted file mode 100644 index e62cc69..0000000 --- a/db/migrate/20170103171414_add_test_and_public_to_projects.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddTestAndPublicToProjects < ActiveRecord::Migration - def change - add_column :projects, :is_test, :boolean, default: false - add_column :projects, :is_public, :boolean, default: false - end -end diff --git a/db/migrate/20170103221846_add_indexes_for_is_test_and_is_public_to_projects.rb b/db/migrate/20170103221846_add_indexes_for_is_test_and_is_public_to_projects.rb deleted file mode 100644 index 1768ab2..0000000 --- a/db/migrate/20170103221846_add_indexes_for_is_test_and_is_public_to_projects.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddIndexesForIsTestAndIsPublicToProjects < ActiveRecord::Migration - def change - add_index :projects, [:id, :is_test, :is_public] - end -end diff --git a/db/migrate/20170105165111_create_visibilities.rb b/db/migrate/20170105165111_create_visibilities.rb new file mode 100644 index 0000000..5e72ee1 --- /dev/null +++ b/db/migrate/20170105165111_create_visibilities.rb @@ -0,0 +1,11 @@ +class CreateVisibilities < ActiveRecord::Migration + def change + create_table :visibilities do |t| + t.string :name + t.boolean :default, default: false + t.timestamps + end + + add_reference :projects, :visibility, foreign_key: true + end +end diff --git a/db/schema.rb b/db/schema.rb index 9ef95ef..c885587 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170103221846) do +ActiveRecord::Schema.define(version: 20170105165111) do create_table "answers", force: :cascade do |t| t.text "text", limit: 65535 @@ -87,7 +87,7 @@ end create_table "friendly_id_slugs", force: :cascade do |t| - t.string "slug", limit: 255, null: false + t.string "slug", limit: 191, null: false t.integer "sluggable_id", limit: 4, null: false t.string "sluggable_type", limit: 40 t.datetime "created_at" @@ -197,7 +197,7 @@ t.integer "dmptemplate_id", limit: 4 t.datetime "created_at" t.datetime "updated_at" - t.string "slug", limit: 255 + t.string "slug", limit: 191 end add_index "phases", ["dmptemplate_id"], name: "index_phases_on_dmptemplate_id", using: :btree @@ -242,7 +242,7 @@ t.integer "dmptemplate_id", limit: 4 t.datetime "created_at" t.datetime "updated_at" - t.string "slug", limit: 255 + t.string "slug", limit: 191 t.integer "organisation_id", limit: 4 t.string "grant_number", limit: 255 t.string "identifier", limit: 255 @@ -251,12 +251,11 @@ t.string "principal_investigator_identifier", limit: 255 t.string "data_contact", limit: 255 t.string "funder_name", limit: 255 - t.boolean "is_test", default: false - t.boolean "is_public", default: false + t.integer "visibility_id", limit: 4 end - add_index "projects", ["id", "is_test", "is_public"], name: "index_projects_on_id_and_is_test_and_is_public", using: :btree add_index "projects", ["slug"], name: "index_projects_on_slug", unique: true, using: :btree + add_index "projects", ["visibility_id"], name: "fk_rails_391d5d7362", using: :btree create_table "question_formats", force: :cascade do |t| t.string "title", limit: 255 @@ -299,7 +298,7 @@ end create_table "roles", force: :cascade do |t| - t.string "name", limit: 255 + t.string "name", limit: 191 t.datetime "created_at" t.datetime "updated_at" t.boolean "role_in_plans" @@ -322,10 +321,10 @@ end create_table "settings", force: :cascade do |t| - t.string "var", limit: 255, null: false + t.string "var", limit: 191, null: false t.text "value", limit: 65535 t.integer "target_id", limit: 4, null: false - t.string "target_type", limit: 255, null: false + t.string "target_type", limit: 191, null: false t.datetime "created_at" t.datetime "updated_at" end @@ -402,7 +401,7 @@ create_table "users", force: :cascade do |t| t.string "firstname", limit: 255 t.string "surname", limit: 255 - t.string "email", limit: 255, default: "", null: false + t.string "email", limit: 191, default: "", null: false t.string "orcid_id", limit: 255 t.string "shibboleth_id", limit: 255 t.integer "user_type_id", limit: 4 @@ -410,7 +409,7 @@ t.datetime "created_at" t.datetime "updated_at" t.string "encrypted_password", limit: 255, default: "" - t.string "reset_password_token", limit: 255 + t.string "reset_password_token", limit: 191 t.datetime "reset_password_sent_at" t.datetime "remember_created_at" t.integer "sign_in_count", limit: 4, default: 0 @@ -418,10 +417,10 @@ t.datetime "last_sign_in_at" t.string "current_sign_in_ip", limit: 255 t.string "last_sign_in_ip", limit: 255 - t.string "confirmation_token", limit: 255 + t.string "confirmation_token", limit: 191 t.datetime "confirmed_at" t.datetime "confirmation_sent_at" - t.string "invitation_token", limit: 255 + t.string "invitation_token", limit: 191 t.datetime "invitation_created_at" t.datetime "invitation_sent_at" t.datetime "invitation_accepted_at" @@ -459,6 +458,14 @@ add_index "versions", ["phase_id"], name: "index_versions_on_phase_id", using: :btree + create_table "visibilities", force: :cascade do |t| + t.string "name", limit: 255 + t.boolean "default", default: false + t.datetime "created_at" + t.datetime "updated_at" + end + + add_foreign_key "projects", "visibilities" add_foreign_key "user_identifiers", "identifier_schemes" add_foreign_key "user_identifiers", "users" end diff --git a/db/seeds.rb b/db/seeds.rb index 526cf3a..d8d159f 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -6,6 +6,14 @@ d1 = DateTime.new(2015, 6, 22) +visibilities = { + test: {name: 'test', default: false}, + private: {name: 'private', default: false}, + organisational: {name: 'organisational', default: true}, + public: {name: 'public', default: false} +} +visibilities.map{ |v| Visibility.create!(v) } + languages = { 'English(UK)' => { abbreviation: 'en-UK',