From 4bc0a04106e07cdce3b2a80c831929945b0a55b1 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Tue, 30 Jul 2024 18:26:53 +0200 Subject: [PATCH] chore(schema): add contact_forms --- app/models/contact_form.rb | 2 ++ .../20240729160650_create_contact_forms.rb | 17 +++++++++++++++++ db/schema.rb | 18 +++++++++++++++++- spec/factories/contact_form.rb | 14 ++++++++++++++ 4 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 app/models/contact_form.rb create mode 100644 db/migrate/20240729160650_create_contact_forms.rb create mode 100644 spec/factories/contact_form.rb diff --git a/app/models/contact_form.rb b/app/models/contact_form.rb new file mode 100644 index 000000000..d2a3495e1 --- /dev/null +++ b/app/models/contact_form.rb @@ -0,0 +1,2 @@ +class ContactForm < ApplicationRecord +end diff --git a/db/migrate/20240729160650_create_contact_forms.rb b/db/migrate/20240729160650_create_contact_forms.rb new file mode 100644 index 000000000..7100760f7 --- /dev/null +++ b/db/migrate/20240729160650_create_contact_forms.rb @@ -0,0 +1,17 @@ +class CreateContactForms < ActiveRecord::Migration[7.0] + def change + create_table :contact_forms do |t| + t.string :email + t.string :subject, null: false + t.text :text, null: false + t.string :question_type, null: false + t.references :user, null: true, foreign_key: true + t.bigint :dossier_id # not a reference (dossier may not exist) + t.string :phone + t.string :tags, array: true, default: [] + t.boolean :for_admin, default: false, null: false + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 0544b546c..49687353a 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[7.0].define(version: 2024_07_16_091043) do +ActiveRecord::Schema[7.0].define(version: 2024_07_29_160650) do # These are extensions that must be enabled in order to support this database enable_extension "pg_buffercache" enable_extension "pg_stat_statements" @@ -315,6 +315,21 @@ ActiveRecord::Schema[7.0].define(version: 2024_07_16_091043) do t.index ["instructeur_id"], name: "index_commentaires_on_instructeur_id" end + create_table "contact_forms", force: :cascade do |t| + t.datetime "created_at", null: false + t.bigint "dossier_id" + t.string "email" + t.boolean "for_admin", default: false, null: false + t.string "phone" + t.string "question_type", null: false + t.string "subject", null: false + t.string "tags", default: [], array: true + t.text "text", null: false + t.datetime "updated_at", null: false + t.bigint "user_id" + t.index ["user_id"], name: "index_contact_forms_on_user_id" + end + create_table "contact_informations", force: :cascade do |t| t.text "adresse", null: false t.datetime "created_at", null: false @@ -1229,6 +1244,7 @@ ActiveRecord::Schema[7.0].define(version: 2024_07_16_091043) do add_foreign_key "commentaires", "dossiers" add_foreign_key "commentaires", "experts" add_foreign_key "commentaires", "instructeurs" + add_foreign_key "contact_forms", "users" add_foreign_key "contact_informations", "groupe_instructeurs" add_foreign_key "dossier_assignments", "dossiers" add_foreign_key "dossier_batch_operations", "batch_operations" diff --git a/spec/factories/contact_form.rb b/spec/factories/contact_form.rb new file mode 100644 index 000000000..a0da9e2bf --- /dev/null +++ b/spec/factories/contact_form.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :contact_form do + user { nil } + email { 'test@example.com' } + dossier_id { nil } + subject { 'Test Subject' } + text { 'Test Content' } + question_type { 'lost_user' } + tags { ['test tag'] } + phone { nil } + end +end