feat(medusa): Remove sqlite support (#4026)

This commit is contained in:
Oliver Windall Juhl
2023-05-17 12:13:36 +02:00
committed by GitHub
parent e2d29d35c4
commit a91987fab3
17 changed files with 148 additions and 415 deletions
@@ -1,52 +1,12 @@
import path from "path"
import { Column, ColumnOptions, ColumnType } from "typeorm"
import getConfigFile from "./get-config-file"
const pgSqliteTypeMapping: { [key: string]: ColumnType } = {
increment: "rowid",
timestamptz: "datetime",
jsonb: "simple-json",
enum: "text",
}
const pgSqliteGenerationMapping: {
[key: string]: "increment" | "uuid" | "rowid"
} = {
increment: "rowid",
}
let dbType: string
export function resolveDbType(pgSqlType: ColumnType): ColumnType {
if (!dbType) {
const { configModule } = getConfigFile(
path.resolve("."),
`medusa-config`
) as any
dbType = configModule?.projectConfig?.database_type || "postgres"
}
if (dbType === "sqlite" && (pgSqlType as string) in pgSqliteTypeMapping) {
return pgSqliteTypeMapping[pgSqlType.toString()]
}
return pgSqlType
}
export function resolveDbGenerationStrategy(
pgSqlType: "increment" | "uuid" | "rowid"
): "increment" | "uuid" | "rowid" {
if (!dbType) {
const { configModule } = getConfigFile(
path.resolve("."),
`medusa-config`
) as any
dbType = configModule?.projectConfig?.database_type || "postgres"
}
if (dbType === "sqlite" && pgSqlType in pgSqliteTypeMapping) {
return pgSqliteGenerationMapping[pgSqlType]
}
return pgSqlType
}