Migration de la base de données : SQLite vers PostgreSQL #56

Merged
djalim merged 6 commits from feature/postgresMigration into develop 2026-04-21 10:07:45 +00:00
2 changed files with 46 additions and 0 deletions
Showing only changes of commit 33b8c178f2 - Show all commits
+14
View File
@@ -0,0 +1,14 @@
import { drizzle } from "npm:drizzle-orm/node-postgres";
import pg from "npm:pg";
const { Pool } = pg;
const pool = new Pool({
host: Deno.env.get("POSTGRES_HOST"),
port: Number(Deno.env.get("POSTGRES_PORT") ?? 5432),
user: Deno.env.get("POSTGRES_USER"),
password: Deno.env.get("POSTGRES_PASS"),
database: Deno.env.get("POSTGRES_DB"),
});
export const db = drizzle(pool);
+32
View File
@@ -0,0 +1,32 @@
import {
date,
integer,
pgTable,
serial,
text,
} from "npm:drizzle-orm/pg-core";
export const promotions = pgTable("promotions", {
id: serial("id").primaryKey(),
endyear: integer("endyear"),
current: integer("current"),
});
export const students = pgTable("students", {
userId: text("userId").primaryKey(),
firstName: text("firstName"),
lastName: text("lastName"),
mail: text("mail"),
promotionId: integer("promotionId").references(() => promotions.id),
});
export const mobility = pgTable("mobility", {
id: serial("id").primaryKey(),
studentId: text("studentId").references(() => students.userId),
startDate: date("startDate"),
endDate: date("endDate"),
weeksCount: integer("weeksCount"),
destinationCountry: text("destinationCountry"),
destinationName: text("destinationName"),
mobilityStatus: text("mobilityStatus").default("N/A"),
});