diff --git a/src/global/commands/g.idose.ts b/src/global/commands/g.idose.ts index 406de0b5..31409efc 100644 --- a/src/global/commands/g.idose.ts +++ b/src/global/commands/g.idose.ts @@ -1,4 +1,4 @@ -import { drug_mass_unit, drug_roa } from '@prisma/client'; +import { $Enums, drug_mass_unit, drug_roa } from '@prisma/client'; import { time, } from 'discord.js'; @@ -153,7 +153,7 @@ async function iDoseSet( drug_id: drugId, route: roa, dose: volume, - units, + units: units.toString() === 'µG' ? $Enums.drug_mass_unit.MICRO_G : units, created_at: date, }, }); diff --git a/src/prisma/tripbot/migrations/20241013014029_add_micro_g_alias/migration.sql b/src/prisma/tripbot/migrations/20241013014029_add_micro_g_alias/migration.sql new file mode 100644 index 00000000..4e28f02e --- /dev/null +++ b/src/prisma/tripbot/migrations/20241013014029_add_micro_g_alias/migration.sql @@ -0,0 +1,14 @@ +/* + Warnings: + + - The values [µG] on the enum `drug_mass_unit` will be removed. If these variants are still used in the database, this will fail. + +*/ +-- AlterEnum +BEGIN; +CREATE TYPE "drug_mass_unit_new" AS ENUM ('MG', 'ML', 'uG', 'G', 'OZ', 'FLOZ'); +ALTER TABLE "user_drug_doses" ALTER COLUMN "units" TYPE "drug_mass_unit_new" USING ("units"::text::"drug_mass_unit_new"); +ALTER TYPE "drug_mass_unit" RENAME TO "drug_mass_unit_old"; +ALTER TYPE "drug_mass_unit_new" RENAME TO "drug_mass_unit"; +DROP TYPE "drug_mass_unit_old"; +COMMIT; diff --git a/src/prisma/tripbot/schema.prisma b/src/prisma/tripbot/schema.prisma index a815453d..621ce537 100644 --- a/src/prisma/tripbot/schema.prisma +++ b/src/prisma/tripbot/schema.prisma @@ -573,7 +573,7 @@ enum drug_category_type { enum drug_mass_unit { MG ML - MICRO_G @map("µG") + MICRO_G @map("uG") G OZ FLOZ