From aa65f6c64a77cf2d2f087d72e722b47da114747d Mon Sep 17 00:00:00 2001 From: Amandine Date: Wed, 25 Sep 2024 15:14:20 +0200 Subject: [PATCH] =?UTF-8?q?Backend=20-=20Ajoute=20les=20comp=C3=A9tences?= =?UTF-8?q?=20banatics?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../collectivite-banatic-competence.table.ts | 24 +++++++++++++++++++ .../action-impact-banatic-competence.table.ts | 24 +++++++++++++++++++ .../models/banatic-competence.table.ts | 6 +++++ 3 files changed, 54 insertions(+) create mode 100644 backend/src/collectivites/models/collectivite-banatic-competence.table.ts create mode 100644 backend/src/panier/models/action-impact-banatic-competence.table.ts create mode 100644 backend/src/taxonomie/models/banatic-competence.table.ts diff --git a/backend/src/collectivites/models/collectivite-banatic-competence.table.ts b/backend/src/collectivites/models/collectivite-banatic-competence.table.ts new file mode 100644 index 00000000000..911b1e57cee --- /dev/null +++ b/backend/src/collectivites/models/collectivite-banatic-competence.table.ts @@ -0,0 +1,24 @@ +import { integer, pgTable } from 'drizzle-orm/pg-core'; +import { collectiviteTable } from './collectivite.table'; +import { primaryKey } from 'drizzle-orm/pg-core/index'; +import { banaticCompetenceTable } from '../../taxonomie/models/banatic-competence.table'; + +export const collectiviteBanaticCompetenceTable = pgTable( + 'collectivite_banatic_competence', + { + collectiviteId: integer('collectivite_id') + .notNull() + .references(() => collectiviteTable.id), + competenceCode: integer('competence_code') + .notNull() + .references(() => banaticCompetenceTable.code), + }, + (table) => { + return { + collectiviteBanaticCompetencePkey: primaryKey({ + columns: [table.collectiviteId, table.competenceCode], + name: 'collectivite_banatic_competence_pkey', + }), + }; + }, +); \ No newline at end of file diff --git a/backend/src/panier/models/action-impact-banatic-competence.table.ts b/backend/src/panier/models/action-impact-banatic-competence.table.ts new file mode 100644 index 00000000000..491434bbd61 --- /dev/null +++ b/backend/src/panier/models/action-impact-banatic-competence.table.ts @@ -0,0 +1,24 @@ +import { integer, pgTable } from 'drizzle-orm/pg-core'; +import { primaryKey } from 'drizzle-orm/pg-core/index'; +import { actionImpactTable } from './action-impact.table'; +import { banaticCompetenceTable } from '../../taxonomie/models/banatic-competence.table'; + +export const actionImpactBanaticCompetenceTable = pgTable( + 'action_impact_banatic_competence', + { + actionImpactId: integer('action_impact_id') + .notNull() + .references(() => actionImpactTable.id), + competenceCode: integer('competence_code') + .notNull() + .references(() => banaticCompetenceTable.code), + }, + (table) => { + return { + action_impact_banatic_competence_pkey: primaryKey({ + columns: [table.actionImpactId, table.competenceCode], + name: 'action_impact_banatic_competence_pkey', + }), + }; + }, +); \ No newline at end of file diff --git a/backend/src/taxonomie/models/banatic-competence.table.ts b/backend/src/taxonomie/models/banatic-competence.table.ts new file mode 100644 index 00000000000..b1adf517891 --- /dev/null +++ b/backend/src/taxonomie/models/banatic-competence.table.ts @@ -0,0 +1,6 @@ +import { integer, pgTable, text } from 'drizzle-orm/pg-core'; + +export const banaticCompetenceTable = pgTable('banatic_competence', { + code: integer('code').primaryKey().notNull(), + nom: text('nom').notNull(), +});