feat(fulfillment): Initialize models work (#6328)
**What** Initialize work on the fulfillment module entities. This pr finally also include the indexes as i was working on some utilities i though it would make sense to test them directly. Also this pr add a new utility to generate proper index for our entity properties. It also include a new monkey patch for the migration generator to handle most of if exists/not exists cases. The monkey patch is a workaround the fact that the transpilation does work well with the ECMA used by mikro orm and therefore we end up with some constructor issue when mikro orm try to instanciate the custom generator class extension. **Comment** - The rule part will likely evolved when we reach the point of rule filtering based data, so no need for details review I believe FIXES CORE-1714 FIXES CORE-1715 FIXES CORE-1718 FIXES CORE-1722 FIXES CORE-1723 Current schema diagram 
This commit is contained in:
committed by
GitHub
parent
512ac1e6ed
commit
3fd68d1979
@@ -0,0 +1,64 @@
|
||||
import { createPsqlIndexStatementHelper } from "../create-psql-index-helper"
|
||||
|
||||
describe("createPsqlIndexStatementHelper", function () {
|
||||
it("should generate a simple index", function () {
|
||||
const options = {
|
||||
name: "index_name",
|
||||
tableName: "table_name",
|
||||
columns: "column_name",
|
||||
}
|
||||
|
||||
const indexStatement = createPsqlIndexStatementHelper(options)
|
||||
expect(indexStatement).toEqual(
|
||||
`CREATE INDEX IF NOT EXISTS ${options.name} ON ${options.tableName} (${options.columns})`
|
||||
)
|
||||
})
|
||||
|
||||
it("should generate a composite index", function () {
|
||||
const options = {
|
||||
name: "index_name",
|
||||
tableName: "table_name",
|
||||
columns: ["column_name_1", "column_name_2"],
|
||||
}
|
||||
|
||||
const indexStatement = createPsqlIndexStatementHelper(options)
|
||||
expect(indexStatement).toEqual(
|
||||
`CREATE INDEX IF NOT EXISTS ${options.name} ON ${
|
||||
options.tableName
|
||||
} (${options.columns.join(", ")})`
|
||||
)
|
||||
})
|
||||
|
||||
it("should generate an index with where clauses", function () {
|
||||
const options = {
|
||||
name: "index_name",
|
||||
tableName: "table_name",
|
||||
columns: ["column_name_1", "column_name_2"],
|
||||
where: "column_name_1 IS NOT NULL",
|
||||
}
|
||||
|
||||
const indexStatement = createPsqlIndexStatementHelper(options)
|
||||
expect(indexStatement).toEqual(
|
||||
`CREATE INDEX IF NOT EXISTS ${options.name} ON ${
|
||||
options.tableName
|
||||
} (${options.columns.join(", ")}) WHERE ${options.where}`
|
||||
)
|
||||
})
|
||||
|
||||
it("should generate an index with where clauses and index type", function () {
|
||||
const options = {
|
||||
name: "index_name",
|
||||
tableName: "table_name",
|
||||
columns: ["column_name_1", "column_name_2"],
|
||||
type: "GIN",
|
||||
where: "column_name_1 IS NOT NULL",
|
||||
}
|
||||
|
||||
const indexStatement = createPsqlIndexStatementHelper(options)
|
||||
expect(indexStatement).toEqual(
|
||||
`CREATE INDEX IF NOT EXISTS ${options.name} ON ${
|
||||
options.tableName
|
||||
} USING GIN (${options.columns.join(", ")}) WHERE ${options.where}`
|
||||
)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user