From 219eaf0d5e1bbb39ba256e7a14d32930ce674525 Mon Sep 17 00:00:00 2001 From: Christophe Robillard Date: Wed, 1 Dec 2021 20:00:29 +0100 Subject: [PATCH] add zone model --- app/models/zone.rb | 13 +++++++++++++ db/migrate/20211127133549_create_zones.rb | 10 ++++++++++ db/schema.rb | 9 ++++++++- 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 app/models/zone.rb create mode 100644 db/migrate/20211127133549_create_zones.rb diff --git a/app/models/zone.rb b/app/models/zone.rb new file mode 100644 index 000000000..31383ffc5 --- /dev/null +++ b/app/models/zone.rb @@ -0,0 +1,13 @@ +# == Schema Information +# +# Table name: zones +# +# id :bigint not null, primary key +# acronym :string +# label :string +# created_at :datetime not null +# updated_at :datetime not null +# +class Zone < ApplicationRecord + validates :acronym, presence: true, uniqueness: true +end diff --git a/db/migrate/20211127133549_create_zones.rb b/db/migrate/20211127133549_create_zones.rb new file mode 100644 index 000000000..d98b30b2d --- /dev/null +++ b/db/migrate/20211127133549_create_zones.rb @@ -0,0 +1,10 @@ +class CreateZones < ActiveRecord::Migration[6.1] + def change + create_table :zones do |t| + t.string :acronym + t.string :label + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 9d45dd8de..6cd7e79c8 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: 2021_11_26_150915) do +ActiveRecord::Schema.define(version: 2021_11_27_133549) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -823,6 +823,13 @@ ActiveRecord::Schema.define(version: 2021_11_26_150915) do t.index ["procedure_id"], name: "index_without_continuation_mails_on_procedure_id" end + create_table "zones", force: :cascade do |t| + t.string "acronym" + t.string "label" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + end + add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id" add_foreign_key "archives_groupe_instructeurs", "archives" add_foreign_key "archives_groupe_instructeurs", "groupe_instructeurs"