From ab0782530ca108d6fb50ee99342fc81bba31d569 Mon Sep 17 00:00:00 2001 From: kara Diaby Date: Thu, 22 Jul 2021 14:34:07 +0200 Subject: [PATCH] create Bulk Message model and migration --- app/models/bulk_message.rb | 18 ++++++++++++++++++ ...0210722083911_create_bulk_message_mails.rb | 18 ++++++++++++++++++ db/schema.rb | 19 +++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 app/models/bulk_message.rb create mode 100644 db/migrate/20210722083911_create_bulk_message_mails.rb diff --git a/app/models/bulk_message.rb b/app/models/bulk_message.rb new file mode 100644 index 000000000..376e231ad --- /dev/null +++ b/app/models/bulk_message.rb @@ -0,0 +1,18 @@ +# == Schema Information +# +# Table name: bulk_messages +# +# id :bigint not null, primary key +# body :text not null +# dossier_count :integer +# dossier_state :string +# sent_at :datetime not null +# created_at :datetime not null +# updated_at :datetime not null +# instructeur_id :bigint not null +# +class BulkMessage < ApplicationRecord + belongs_to :instructeur + has_one_attached :piece_jointe + has_and_belongs_to_many :groupe_instructeurs +end diff --git a/db/migrate/20210722083911_create_bulk_message_mails.rb b/db/migrate/20210722083911_create_bulk_message_mails.rb new file mode 100644 index 000000000..994140f7d --- /dev/null +++ b/db/migrate/20210722083911_create_bulk_message_mails.rb @@ -0,0 +1,18 @@ +class CreateBulkMessageMails < ActiveRecord::Migration[6.1] + def change + create_table :bulk_messages do |t| + t.text :body, null: false + t.integer :dossier_count + t.string :dossier_state + t.datetime :sent_at, null: false + t.bigint :instructeur_id, null: false + + t.timestamps + end + + create_join_table :bulk_messages, :groupe_instructeurs, column_options: { null: true, foreign_key: true } do |t| + t.index :bulk_message_id + t.index :groupe_instructeur_id, name: :index_bulk_messages_groupe_instructeurs_on_gi_id + end + end +end diff --git a/db/schema.rb b/db/schema.rb index c642e473e..ce3af1e14 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -156,6 +156,23 @@ ActiveRecord::Schema.define(version: 2021_07_22_133553) do t.datetime "updated_at", null: false end + create_table "bulk_messages", force: :cascade do |t| + t.text "body", null: false + t.integer "dossier_count" + t.string "dossier_state" + t.datetime "sent_at", null: false + t.bigint "instructeur_id", null: false + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + end + + create_table "bulk_messages_groupe_instructeurs", id: false, force: :cascade do |t| + t.bigint "bulk_message_id" + t.bigint "groupe_instructeur_id" + t.index ["bulk_message_id"], name: "index_bulk_messages_groupe_instructeurs_on_bulk_message_id" + t.index ["groupe_instructeur_id"], name: "index_bulk_messages_groupe_instructeurs_on_gi_id" + end + create_table "champs", id: :serial, force: :cascade do |t| t.string "value" t.integer "type_de_champ_id" @@ -767,6 +784,8 @@ ActiveRecord::Schema.define(version: 2021_07_22_133553) do add_foreign_key "attestation_templates", "procedures" add_foreign_key "attestations", "dossiers" add_foreign_key "avis", "experts_procedures" + add_foreign_key "bulk_messages_groupe_instructeurs", "bulk_messages" + add_foreign_key "bulk_messages_groupe_instructeurs", "groupe_instructeurs" add_foreign_key "champs", "champs", column: "parent_id" add_foreign_key "closed_mails", "procedures" add_foreign_key "commentaires", "dossiers"