From eadac724b59bb2f824f146c50ff5cfd3d9f569be Mon Sep 17 00:00:00 2001 From: Rami Abdou Date: Thu, 4 Apr 2024 15:23:29 -0700 Subject: [PATCH 1/4] rename migration files --- .../{2024-01-29T17:23:16Z-init.ts => 20240129172316_init.ts} | 0 ...4-01-29T19:05:29Z-birthdate.ts => 20240129190529_birthdate.ts} | 0 ...-12T21:28:42Z-fix-removal.ts => 20240212212842_fix_removal.ts} | 0 ...03-11T10:33:01Z-job_offers.ts => 20240311103301_job_offers.ts} | 0 ...ay-notification.ts => 20240318170613_birthday_notification.ts} | 0 ...26Z-birthday-default.ts => 20240318194526_birthday_default.ts} | 0 ...-31T21:37:51Z-share-email.ts => 20240331213751_share_email.ts} | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename packages/db/src/migrations/{2024-01-29T17:23:16Z-init.ts => 20240129172316_init.ts} (100%) rename packages/db/src/migrations/{2024-01-29T19:05:29Z-birthdate.ts => 20240129190529_birthdate.ts} (100%) rename packages/db/src/migrations/{2024-02-12T21:28:42Z-fix-removal.ts => 20240212212842_fix_removal.ts} (100%) rename packages/db/src/migrations/{2024-03-11T10:33:01Z-job_offers.ts => 20240311103301_job_offers.ts} (100%) rename packages/db/src/migrations/{2024-03-18T17:06:13Z-birthday-notification.ts => 20240318170613_birthday_notification.ts} (100%) rename packages/db/src/migrations/{2024-03-18T19:45:26Z-birthday-default.ts => 20240318194526_birthday_default.ts} (100%) rename packages/db/src/migrations/{2024-03-31T21:37:51Z-share-email.ts => 20240331213751_share_email.ts} (100%) diff --git a/packages/db/src/migrations/2024-01-29T17:23:16Z-init.ts b/packages/db/src/migrations/20240129172316_init.ts similarity index 100% rename from packages/db/src/migrations/2024-01-29T17:23:16Z-init.ts rename to packages/db/src/migrations/20240129172316_init.ts diff --git a/packages/db/src/migrations/2024-01-29T19:05:29Z-birthdate.ts b/packages/db/src/migrations/20240129190529_birthdate.ts similarity index 100% rename from packages/db/src/migrations/2024-01-29T19:05:29Z-birthdate.ts rename to packages/db/src/migrations/20240129190529_birthdate.ts diff --git a/packages/db/src/migrations/2024-02-12T21:28:42Z-fix-removal.ts b/packages/db/src/migrations/20240212212842_fix_removal.ts similarity index 100% rename from packages/db/src/migrations/2024-02-12T21:28:42Z-fix-removal.ts rename to packages/db/src/migrations/20240212212842_fix_removal.ts diff --git a/packages/db/src/migrations/2024-03-11T10:33:01Z-job_offers.ts b/packages/db/src/migrations/20240311103301_job_offers.ts similarity index 100% rename from packages/db/src/migrations/2024-03-11T10:33:01Z-job_offers.ts rename to packages/db/src/migrations/20240311103301_job_offers.ts diff --git a/packages/db/src/migrations/2024-03-18T17:06:13Z-birthday-notification.ts b/packages/db/src/migrations/20240318170613_birthday_notification.ts similarity index 100% rename from packages/db/src/migrations/2024-03-18T17:06:13Z-birthday-notification.ts rename to packages/db/src/migrations/20240318170613_birthday_notification.ts diff --git a/packages/db/src/migrations/2024-03-18T19:45:26Z-birthday-default.ts b/packages/db/src/migrations/20240318194526_birthday_default.ts similarity index 100% rename from packages/db/src/migrations/2024-03-18T19:45:26Z-birthday-default.ts rename to packages/db/src/migrations/20240318194526_birthday_default.ts diff --git a/packages/db/src/migrations/2024-03-31T21:37:51Z-share-email.ts b/packages/db/src/migrations/20240331213751_share_email.ts similarity index 100% rename from packages/db/src/migrations/2024-03-31T21:37:51Z-share-email.ts rename to packages/db/src/migrations/20240331213751_share_email.ts From 4ad2c7725e6ddcdd03520ec463f3803ea56d0deb Mon Sep 17 00:00:00 2001 From: Rami Abdou Date: Thu, 4 Apr 2024 15:36:24 -0700 Subject: [PATCH 2/4] update docs --- docs/how-to-implement-a-database-migration.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/how-to-implement-a-database-migration.md b/docs/how-to-implement-a-database-migration.md index d7d08d1f..2ca89edb 100644 --- a/docs/how-to-implement-a-database-migration.md +++ b/docs/how-to-implement-a-database-migration.md @@ -43,13 +43,17 @@ files in the following manner: For example, a valid migration name is: ``` -2024-01-29T19:05:29Z-birthdate.ts +20240311103301_job_offers.ts ``` -To get the ISO timestamp, you can simply open up a node terminal and run: +## Common Errors ``` -new Date() +An error occurred with the Kysely migrator. Error: corrupted migrations: previously executed migration is missing. ``` -and the output should be exactly what we want. +The easiest way to fix this is to re-setup your database by running: + +``` +yarn db:setup +``` From bc56de9d22d8e5b5a81b4742c36b1dc7fcb0d126 Mon Sep 17 00:00:00 2001 From: Rami Abdou Date: Thu, 4 Apr 2024 15:44:03 -0700 Subject: [PATCH 3/4] update error message --- packages/db/src/use-cases/migrate.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/db/src/use-cases/migrate.ts b/packages/db/src/use-cases/migrate.ts index b3ad18fe..3e68018b 100644 --- a/packages/db/src/use-cases/migrate.ts +++ b/packages/db/src/use-cases/migrate.ts @@ -68,7 +68,12 @@ export async function migrate(options: MigrateOptions = defaultOptions) { } if (error) { - console.error('An error occurred with the Kysely migrator.', error); + console.error( + 'Something went wrong! To debug, see common migration errors here:', + 'https://github.com/colorstackorg/oyster/blob/main/docs/how-to-implement-a-database-migration.md#common-errors.', + error + ); + process.exit(1); } From 48918c9a594b28cd6fe247f0922a782e179d0e8a Mon Sep 17 00:00:00 2001 From: Rami Abdou Date: Thu, 4 Apr 2024 15:44:11 -0700 Subject: [PATCH 4/4] update docs --- docs/how-to-implement-a-database-migration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/how-to-implement-a-database-migration.md b/docs/how-to-implement-a-database-migration.md index 2ca89edb..5ce57348 100644 --- a/docs/how-to-implement-a-database-migration.md +++ b/docs/how-to-implement-a-database-migration.md @@ -49,7 +49,7 @@ For example, a valid migration name is: ## Common Errors ``` -An error occurred with the Kysely migrator. Error: corrupted migrations: previously executed migration is missing. +Error: corrupted migrations: previously executed migration is missing. ``` The easiest way to fix this is to re-setup your database by running: