Skip to content

Commit

Permalink
chore(deps): bump betagouv/moncomptepro to 78370f0 (#362)
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasduteil authored Jun 26, 2024
1 parent 5709ea8 commit 6656974
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 57 deletions.
Binary file modified bun.lockb
Binary file not shown.
24 changes: 0 additions & 24 deletions packages/~/app/api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,11 @@ import readyz_router from "./readyz";

//

// const OpenTelemetry = new NodeSDK({
// traceExporter: new OTLPTraceExporter(),
// instrumentations: [getNodeAutoInstrumentations()],
// // // Sentry config
// spanProcessor: new SentrySpanProcessor(),
// textMapPropagator: new SentryPropagator(),
// // contextManager: new SentryContextManager(),
// // sampler: new SentrySampler(client),
// });
// setOpenTelemetryContextAsyncContextStrategy();
// OpenTelemetry.start();

const authoried = vip_list_guard({ vip_list: config.ALLOWED_USERS.split(",") });
const app = new Hono()
.use("*", logger(consola.info))
.use("*", compress())
.use("*", sentry())
// .use("*", async function ({ req, res, var: { sentry } }, next) {
// const transaction = sentry.startTransaction({
// name: `${req.method} ${req.url}`,
// op: "http.server",
// });

// await next();

// transaction.setName(`${req.method} ${req.routePath}`);
// transaction.setHttpStatus(res.status);
// transaction.finish();
// })

.get("/healthz", ({ text }) => text(`healthz check passed`))
.get("/livez", ({ text }) => text(`livez check passed`))
Expand Down
9 changes: 6 additions & 3 deletions packages/~/infra/moncomptepro/database/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
# Change the DATABASE_URL to match the moncomptepro sandbox or a local moncomptepro database.

# Remove the existing drizzle folder to ignore migration between models.
$ rm -rf database/src/drizzle
$ rm -rf src/drizzle

# One can use a scalingo tunnel to pull from an existing running database
$ scalingo --app moncomptepro-preprod --region osc-secnum-fr1 db-tunnel --identity ~/.ssh/scalingo SCALINGO_POSTGRESQL_URL

# Pull the new schema
$ bun x drizzle-kit introspect

# Test database connection with the studio
$ bun x drizzle-kit studio
drizzle-kit: v0.21.2
Expand All @@ -24,8 +27,6 @@ Using 'pg' driver for database querying

Drizzle Studio is up and running on https://local.drizzle.studio

# Pull the new schema
$ bun x drizzle-kit introspect

# Format the generated code
$ bun x prettier -w .
Expand All @@ -39,7 +40,9 @@ $ sed -i "s/.default('1970-01-01 00:00:00'::timestamp without time zone)/.defaul
$ bun x prettier -w .

# You might want to use an empty database to
$ docker compose stop
$ docker volume rm moncomptepro_postgres
$ docker compose up --build --detach

# Uncomment the generated database/src/drizzle/0000_xxxxxxx.sql snapshot
# And run the migration on your local empty database
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ CREATE TABLE IF NOT EXISTS "users" (
"email_verified_at" timestamp with time zone,
"current_challenge" varchar,
"needs_inclusionconnect_welcome_page" boolean DEFAULT false NOT NULL,
"needs_inclusionconnect_onboarding_help" boolean DEFAULT false NOT NULL
"needs_inclusionconnect_onboarding_help" boolean DEFAULT false NOT NULL,
"encrypted_totp_key" varchar,
"totp_key_verified_at" timestamp with time zone,
"force_2fa" boolean DEFAULT false NOT NULL
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "users_oidc_clients" (
Expand Down Expand Up @@ -158,6 +161,6 @@ EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
CREATE UNIQUE INDEX IF NOT EXISTS "index_organizations_on_siret" ON "organizations" ("siret");--> statement-breakpoint
CREATE UNIQUE INDEX IF NOT EXISTS "index_users_on_email" ON "users" ("email");--> statement-breakpoint
CREATE UNIQUE INDEX IF NOT EXISTS "index_users_on_reset_password_token" ON "users" ("reset_password_token");
CREATE UNIQUE INDEX IF NOT EXISTS "index_organizations_on_siret" ON "organizations" USING btree ("siret" text_ops);--> statement-breakpoint
CREATE UNIQUE INDEX IF NOT EXISTS "index_users_on_email" ON "users" USING btree ("email" text_ops);--> statement-breakpoint
CREATE UNIQUE INDEX IF NOT EXISTS "index_users_on_reset_password_token" ON "users" USING btree ("reset_password_token" text_ops);
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "00000000-0000-0000-0000-000000000000",
"prevId": "",
"version": "6",
"version": "7",
"dialect": "postgresql",
"tables": {
"public.moderations": {
Expand Down Expand Up @@ -365,8 +365,19 @@
"indexes": {
"index_organizations_on_siret": {
"name": "index_organizations_on_siret",
"columns": ["siret"],
"isUnique": true
"columns": [
{
"expression": "siret",
"asc": true,
"nulls": "last",
"opclass": "text_ops",
"isExpression": false
}
],
"isUnique": true,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {},
Expand Down Expand Up @@ -514,18 +525,59 @@
"primaryKey": false,
"notNull": true,
"default": false
},
"encrypted_totp_key": {
"name": "encrypted_totp_key",
"type": "varchar",
"primaryKey": false,
"notNull": false
},
"totp_key_verified_at": {
"name": "totp_key_verified_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": false
},
"force_2fa": {
"name": "force_2fa",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": false
}
},
"indexes": {
"index_users_on_email": {
"name": "index_users_on_email",
"columns": ["email"],
"isUnique": true
"columns": [
{
"expression": "email",
"asc": true,
"nulls": "last",
"opclass": "text_ops",
"isExpression": false
}
],
"isUnique": true,
"concurrently": false,
"method": "btree",
"with": {}
},
"index_users_on_reset_password_token": {
"name": "index_users_on_reset_password_token",
"columns": ["reset_password_token"],
"isUnique": true
"columns": [
{
"expression": "reset_password_token",
"asc": true,
"nulls": "last",
"opclass": "text_ops",
"isExpression": false
}
],
"isUnique": true,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"version": "6",
"version": "7",
"dialect": "postgresql",
"entries": [
{
"idx": 0,
"version": "6",
"when": 1716307849916,
"tag": "0000_fat_jetstream",
"version": "7",
"when": 1719396314015,
"tag": "0000_curved_reavers",
"breakpoints": true
}
]
Expand Down
15 changes: 12 additions & 3 deletions packages/~/infra/moncomptepro/database/src/drizzle/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export const organizations = pgTable(
return {
index_organizations_on_siret: uniqueIndex(
"index_organizations_on_siret",
).on(table.siret),
).using("btree", table.siret),
};
},
);
Expand Down Expand Up @@ -181,13 +181,22 @@ export const users = pgTable(
)
.default(false)
.notNull(),
encrypted_totp_key: varchar("encrypted_totp_key"),
totp_key_verified_at: timestamp("totp_key_verified_at", {
withTimezone: true,
mode: "string",
}),
force_2fa: boolean("force_2fa").default(false).notNull(),
},
(table) => {
return {
index_users_on_email: uniqueIndex("index_users_on_email").on(table.email),
index_users_on_email: uniqueIndex("index_users_on_email").using(
"btree",
table.email,
),
index_users_on_reset_password_token: uniqueIndex(
"index_users_on_reset_password_token",
).on(table.reset_password_token),
).using("btree", table.reset_password_token),
};
},
);
Expand Down
16 changes: 6 additions & 10 deletions packages/~/infra/moncomptepro/database/src/seed/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,31 @@ export async function delete_database(db: MonComptePro_PgDatabase) {
const users_organizations = await db
.delete(schema.users_organizations)
.returning();
consola.verbose(
`🚮 DELETE ${users_organizations.length} users_organizations`,
);
consola.info(`🚮 DELETE ${users_organizations.length} users_organizations`);

const users_oidc_clients = await db
.delete(schema.users_oidc_clients)
.returning();
await db.execute(
sql`ALTER SEQUENCE users_oidc_clients_id_seq RESTART WITH 1`,
);
consola.verbose(
`🚮 DELETE ${users_oidc_clients.length} users_oidc_clients`,
);
consola.info(`🚮 DELETE ${users_oidc_clients.length} users_oidc_clients`);

const oidc_clients = await db.delete(schema.oidc_clients).returning();
await db.execute(sql`ALTER SEQUENCE oidc_clients_id_seq RESTART WITH 1`);
consola.verbose(`🚮 DELETE ${oidc_clients.length} oidc_clients`);
consola.info(`🚮 DELETE ${oidc_clients.length} oidc_clients`);

const users = await db.delete(schema.users).returning();
await db.execute(sql`ALTER SEQUENCE users_id_seq RESTART WITH 1`);
consola.verbose(`🚮 DELETE ${users.length} users`);
consola.info(`🚮 DELETE ${users.length} users`);

const organizations = await db.delete(schema.organizations).returning();
await db.execute(sql`ALTER SEQUENCE organizations_id_seq RESTART WITH 1`);
consola.verbose(`🚮 DELETE ${organizations.length} organizations`);
consola.info(`🚮 DELETE ${organizations.length} organizations`);

const moderations = await db.delete(schema.moderations).returning();
await db.execute(sql`ALTER SEQUENCE moderations_id_seq RESTART WITH 1`);
consola.verbose(`🚮 DELETE ${moderations.length} moderations`);
consola.info(`🚮 DELETE ${moderations.length} moderations`);
} catch (err) {
console.error("Something went wrong...");
console.error(err);
Expand Down
2 changes: 1 addition & 1 deletion packages/~/infra/moncomptepro/database/src/seed/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export async function seed() {
await client.connect();

const db = drizzle(client, {
logger: consola.level >= LogLevels.verbose,
logger: consola.level >= LogLevels.debug,
schema,
});

Expand Down
2 changes: 1 addition & 1 deletion packages/~/infra/moncomptepro/lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
},
"devDependencies": {
"@~/config.typescript": "workspace:*",
"moncomptepro": "betagouv/moncomptepro#539729e6544b787b94060e96c4a457ef6c7227af"
"moncomptepro": "betagouv/moncomptepro#78370f0e27b34323c83ee460a39ddeef401ce10a"
}
}

0 comments on commit 6656974

Please sign in to comment.