From edca75148a07a52dc2d5b966a83a836c27781780 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Sat, 8 Dec 2018 11:40:02 +0100 Subject: [PATCH 1/2] Drop the now useless rna_informations table --- .../20181221103901_drop_rna_informations.rb | 5 +++++ db/schema.rb | 15 +-------------- 2 files changed, 6 insertions(+), 14 deletions(-) create mode 100644 db/migrate/20181221103901_drop_rna_informations.rb diff --git a/db/migrate/20181221103901_drop_rna_informations.rb b/db/migrate/20181221103901_drop_rna_informations.rb new file mode 100644 index 000000000..39bd0d75c --- /dev/null +++ b/db/migrate/20181221103901_drop_rna_informations.rb @@ -0,0 +1,5 @@ +class DropRNAInformations < ActiveRecord::Migration[5.2] + def change + drop_table :rna_informations + end +end diff --git a/db/schema.rb b/db/schema.rb index 2a8ec1ccc..3e9f70e72 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: 2018_12_18_204707) do +ActiveRecord::Schema.define(version: 2018_12_21_103901) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -497,19 +497,6 @@ ActiveRecord::Schema.define(version: 2018_12_18_204707) do t.index ["procedure_id"], name: "index_refused_mails_on_procedure_id" end - create_table "rna_informations", id: :serial, force: :cascade do |t| - t.string "association_id" - t.string "titre" - t.text "objet" - t.date "date_creation" - t.date "date_declaration" - t.date "date_publication" - t.integer "entreprise_id" - t.datetime "created_at" - t.datetime "updated_at" - t.index ["entreprise_id"], name: "index_rna_informations_on_entreprise_id" - end - create_table "services", force: :cascade do |t| t.string "type_organisme", null: false t.string "nom", null: false From a9d4672de1b7c77048180cbfc70df5697e7ebb2e Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Sat, 8 Dec 2018 11:41:41 +0100 Subject: [PATCH 2/2] Remove sql views --- db/views/searches_v01.sql | 59 --------------------------------------- db/views/searches_v02.sql | 43 ---------------------------- db/views/searches_v03.sql | 41 --------------------------- db/views/searches_v04.sql | 39 -------------------------- 4 files changed, 182 deletions(-) delete mode 100644 db/views/searches_v01.sql delete mode 100644 db/views/searches_v02.sql delete mode 100644 db/views/searches_v03.sql delete mode 100644 db/views/searches_v04.sql diff --git a/db/views/searches_v01.sql b/db/views/searches_v01.sql deleted file mode 100644 index e5f2cfd71..000000000 --- a/db/views/searches_v01.sql +++ /dev/null @@ -1,59 +0,0 @@ --- this version allows to search for a single term within many tables, --- but behaves badly with multiple terms scattered in multiple tables. - -SELECT dossiers.id AS dossier_id, - dossiers.id::text || ' ' || - COALESCE(users.email, '') AS term - FROM dossiers - INNER JOIN users ON users.id = dossiers.user_id - -UNION SELECT cerfas.dossier_id, - COALESCE(cerfas.content, '') AS term - FROM cerfas - -UNION SELECT champs.dossier_id, - COALESCE(champs.value, '') || ' ' || - COALESCE(drop_down_lists.value, '') AS term - FROM champs - INNER JOIN drop_down_lists ON drop_down_lists.type_de_champ_id = champs.type_de_champ_id - -UNION SELECT entreprises.dossier_id, - COALESCE(entreprises.siren, '') || ' ' || - COALESCE(entreprises.numero_tva_intracommunautaire, '') || ' ' || - COALESCE(entreprises.forme_juridique, '') || ' ' || - COALESCE(entreprises.forme_juridique_code, '') || ' ' || - COALESCE(entreprises.nom_commercial, '') || ' ' || - COALESCE(entreprises.raison_sociale, '') || ' ' || - COALESCE(entreprises.siret_siege_social, '') || ' ' || - COALESCE(entreprises.nom, '') || ' ' || - COALESCE(entreprises.prenom, '') || ' ' || - COALESCE(rna_informations.association_id, '') || ' ' || - COALESCE(rna_informations.titre, '') || ' ' || - COALESCE(rna_informations.objet, '') AS term - FROM entreprises - LEFT JOIN rna_informations ON rna_informations.entreprise_id = entreprises.id - -UNION SELECT etablissements.dossier_id, - COALESCE(etablissements.siret, '') || ' ' || - COALESCE(etablissements.naf, '') || ' ' || - COALESCE(etablissements.libelle_naf, '') || ' ' || - COALESCE(etablissements.adresse, '') || ' ' || - COALESCE(etablissements.code_postal, '') || ' ' || - COALESCE(etablissements.localite, '') || ' ' || - COALESCE(etablissements.code_insee_localite, '') AS term - FROM etablissements - -UNION SELECT individuals.dossier_id, - COALESCE(individuals.nom, '') || ' ' || - COALESCE(individuals.prenom, '') AS term - FROM individuals - -UNION SELECT pieces_justificatives.dossier_id, - COALESCE(pieces_justificatives.content, '') AS term - FROM pieces_justificatives - -UNION SELECT dossiers.id, - COALESCE(france_connect_informations.given_name, '') || ' ' || - COALESCE(france_connect_informations.family_name, '') AS term - FROM france_connect_informations - INNER JOIN dossiers ON dossiers.user_id = france_connect_informations.user_id diff --git a/db/views/searches_v02.sql b/db/views/searches_v02.sql deleted file mode 100644 index 8a168f465..000000000 --- a/db/views/searches_v02.sql +++ /dev/null @@ -1,43 +0,0 @@ --- this version merges all possible search terms together, complicating the --- view, but enables searching for multiple terms from multiple tables at once. - -SELECT dossiers.id AS dossier_id, - COALESCE(users.email, '') || ' ' || - COALESCE(france_connect_informations.given_name, '') || ' ' || - COALESCE(france_connect_informations.family_name, '') || ' ' || - COALESCE(cerfas.content, '') || ' ' || - COALESCE(champs.value, '') || ' ' || - COALESCE(drop_down_lists.value, '') || ' ' || - COALESCE(entreprises.siren, '') || ' ' || - COALESCE(entreprises.numero_tva_intracommunautaire, '') || ' ' || - COALESCE(entreprises.forme_juridique, '') || ' ' || - COALESCE(entreprises.forme_juridique_code, '') || ' ' || - COALESCE(entreprises.nom_commercial, '') || ' ' || - COALESCE(entreprises.raison_sociale, '') || ' ' || - COALESCE(entreprises.siret_siege_social, '') || ' ' || - COALESCE(entreprises.nom, '') || ' ' || - COALESCE(entreprises.prenom, '') || ' ' || - COALESCE(rna_informations.association_id, '') || ' ' || - COALESCE(rna_informations.titre, '') || ' ' || - COALESCE(rna_informations.objet, '') || ' ' || - COALESCE(etablissements.siret, '') || ' ' || - COALESCE(etablissements.naf, '') || ' ' || - COALESCE(etablissements.libelle_naf, '') || ' ' || - COALESCE(etablissements.adresse, '') || ' ' || - COALESCE(etablissements.code_postal, '') || ' ' || - COALESCE(etablissements.localite, '') || ' ' || - COALESCE(etablissements.code_insee_localite, '') || ' ' || - COALESCE(individuals.nom, '') || ' ' || - COALESCE(individuals.prenom, '') || ' ' || - COALESCE(pieces_justificatives.content, '') AS term -FROM dossiers -INNER JOIN users ON users.id = dossiers.user_id -LEFT JOIN france_connect_informations ON france_connect_informations.user_id = dossiers.user_id -LEFT JOIN cerfas ON cerfas.dossier_id = dossiers.id -LEFT JOIN champs ON champs.dossier_id = dossiers.id -LEFT JOIN drop_down_lists ON drop_down_lists.type_de_champ_id = champs.type_de_champ_id -LEFT JOIN entreprises ON entreprises.dossier_id = dossiers.id -LEFT JOIN rna_informations ON rna_informations.entreprise_id = entreprises.id -LEFT JOIN etablissements ON etablissements.dossier_id = dossiers.id -LEFT JOIN individuals ON individuals.dossier_id = dossiers.id -LEFT JOIN pieces_justificatives ON pieces_justificatives.dossier_id = dossiers.id diff --git a/db/views/searches_v03.sql b/db/views/searches_v03.sql deleted file mode 100644 index f847fc13f..000000000 --- a/db/views/searches_v03.sql +++ /dev/null @@ -1,41 +0,0 @@ --- this version merges all possible search terms together, complicating the --- view, but enables searching for multiple terms from multiple tables at once. - -SELECT dossiers.id AS dossier_id, - COALESCE(users.email, '') || ' ' || - COALESCE(france_connect_informations.given_name, '') || ' ' || - COALESCE(france_connect_informations.family_name, '') || ' ' || - COALESCE(cerfas.content, '') || ' ' || - COALESCE(champs.value, '') || ' ' || - COALESCE(drop_down_lists.value, '') || ' ' || - COALESCE(etablissements.entreprise_siren, '') || ' ' || - COALESCE(etablissements.entreprise_numero_tva_intracommunautaire, '') || ' ' || - COALESCE(etablissements.entreprise_forme_juridique, '') || ' ' || - COALESCE(etablissements.entreprise_forme_juridique_code, '') || ' ' || - COALESCE(etablissements.entreprise_nom_commercial, '') || ' ' || - COALESCE(etablissements.entreprise_raison_sociale, '') || ' ' || - COALESCE(etablissements.entreprise_siret_siege_social, '') || ' ' || - COALESCE(etablissements.entreprise_nom, '') || ' ' || - COALESCE(etablissements.entreprise_prenom, '') || ' ' || - COALESCE(etablissements.association_rna, '') || ' ' || - COALESCE(etablissements.association_titre, '') || ' ' || - COALESCE(etablissements.association_objet, '') || ' ' || - COALESCE(etablissements.siret, '') || ' ' || - COALESCE(etablissements.naf, '') || ' ' || - COALESCE(etablissements.libelle_naf, '') || ' ' || - COALESCE(etablissements.adresse, '') || ' ' || - COALESCE(etablissements.code_postal, '') || ' ' || - COALESCE(etablissements.localite, '') || ' ' || - COALESCE(etablissements.code_insee_localite, '') || ' ' || - COALESCE(individuals.nom, '') || ' ' || - COALESCE(individuals.prenom, '') || ' ' || - COALESCE(pieces_justificatives.content, '') AS term -FROM dossiers -INNER JOIN users ON users.id = dossiers.user_id -LEFT JOIN france_connect_informations ON france_connect_informations.user_id = dossiers.user_id -LEFT JOIN cerfas ON cerfas.dossier_id = dossiers.id -LEFT JOIN champs ON champs.dossier_id = dossiers.id -LEFT JOIN drop_down_lists ON drop_down_lists.type_de_champ_id = champs.type_de_champ_id -LEFT JOIN etablissements ON etablissements.dossier_id = dossiers.id -LEFT JOIN individuals ON individuals.dossier_id = dossiers.id -LEFT JOIN pieces_justificatives ON pieces_justificatives.dossier_id = dossiers.id diff --git a/db/views/searches_v04.sql b/db/views/searches_v04.sql deleted file mode 100644 index f628d2f20..000000000 --- a/db/views/searches_v04.sql +++ /dev/null @@ -1,39 +0,0 @@ --- this version merges all possible search terms together, complicating the --- view, but enables searching for multiple terms from multiple tables at once. - -SELECT dossiers.id AS dossier_id, - COALESCE(users.email, '') || ' ' || - COALESCE(france_connect_informations.given_name, '') || ' ' || - COALESCE(france_connect_informations.family_name, '') || ' ' || - COALESCE(champs.value, '') || ' ' || - COALESCE(drop_down_lists.value, '') || ' ' || - COALESCE(etablissements.entreprise_siren, '') || ' ' || - COALESCE(etablissements.entreprise_numero_tva_intracommunautaire, '') || ' ' || - COALESCE(etablissements.entreprise_forme_juridique, '') || ' ' || - COALESCE(etablissements.entreprise_forme_juridique_code, '') || ' ' || - COALESCE(etablissements.entreprise_nom_commercial, '') || ' ' || - COALESCE(etablissements.entreprise_raison_sociale, '') || ' ' || - COALESCE(etablissements.entreprise_siret_siege_social, '') || ' ' || - COALESCE(etablissements.entreprise_nom, '') || ' ' || - COALESCE(etablissements.entreprise_prenom, '') || ' ' || - COALESCE(etablissements.association_rna, '') || ' ' || - COALESCE(etablissements.association_titre, '') || ' ' || - COALESCE(etablissements.association_objet, '') || ' ' || - COALESCE(etablissements.siret, '') || ' ' || - COALESCE(etablissements.naf, '') || ' ' || - COALESCE(etablissements.libelle_naf, '') || ' ' || - COALESCE(etablissements.adresse, '') || ' ' || - COALESCE(etablissements.code_postal, '') || ' ' || - COALESCE(etablissements.localite, '') || ' ' || - COALESCE(etablissements.code_insee_localite, '') || ' ' || - COALESCE(individuals.nom, '') || ' ' || - COALESCE(individuals.prenom, '') || ' ' || - COALESCE(pieces_justificatives.content, '') AS term -FROM dossiers -INNER JOIN users ON users.id = dossiers.user_id -LEFT JOIN france_connect_informations ON france_connect_informations.user_id = dossiers.user_id -LEFT JOIN champs ON champs.dossier_id = dossiers.id -LEFT JOIN drop_down_lists ON drop_down_lists.type_de_champ_id = champs.type_de_champ_id -LEFT JOIN etablissements ON etablissements.dossier_id = dossiers.id -LEFT JOIN individuals ON individuals.dossier_id = dossiers.id -LEFT JOIN pieces_justificatives ON pieces_justificatives.dossier_id = dossiers.id