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 0000000000..911b1e57ce --- /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 0000000000..491434bbd6 --- /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 0000000000..b1adf51789 --- /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(), +});