MCPcopy
hub / github.com/drizzle-team/drizzle-orm / prepareSQLiteCreateTable

Function prepareSQLiteCreateTable

drizzle-kit/src/jsonStatements.ts:976–1003  ·  view source on GitHub ↗
(
	table: Table,
	action?: 'push' | undefined,
)

Source from the content-addressed store, hash-verified

974};
975
976export const prepareSQLiteCreateTable = (
977 table: Table,
978 action?: 'push' | undefined,
979): JsonSqliteCreateTableStatement => {
980 const { name, columns, uniqueConstraints, checkConstraints } = table;
981
982 const references: string[] = Object.values(table.foreignKeys);
983
984 const composites: string[][] = Object.values(table.compositePrimaryKeys).map(
985 (it) => SQLiteSquasher.unsquashPK(it),
986 );
987
988 const fks = references.map((it) =>
989 action === 'push'
990 ? SQLiteSquasher.unsquashPushFK(it)
991 : SQLiteSquasher.unsquashFK(it)
992 );
993
994 return {
995 type: 'sqlite_create_table',
996 tableName: name,
997 columns: Object.values(columns),
998 referenceData: fks,
999 compositePKs: composites,
1000 uniqueConstraints: Object.values(uniqueConstraints),
1001 checkConstraints: Object.values(checkConstraints),
1002 };
1003};
1004
1005export const prepareDropTableJson = (table: Table): JsonDropTableStatement => {
1006 return {

Callers 2

applySqliteSnapshotsDiffFunction · 0.90
applyLibSQLSnapshotsDiffFunction · 0.90

Calls 1

valuesMethod · 0.45

Tested by

no test coverage detected