Skip to content

Commit

Permalink
replicate generate tables and general singlestore migrations test
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodriguespn committed Aug 13, 2024
1 parent a861f5d commit 8084ad6
Showing 1 changed file with 0 additions and 52 deletions.
52 changes: 0 additions & 52 deletions drizzle-kit/src/cli/commands/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,58 +395,6 @@ export const prepareAndMigrateMysql = async (config: GenerateConfig) => {
}
};

// Not needed for now
function mySingleStoreSchemaSuggestions(
curSchema: TypeOf<typeof singlestoreSchema>,
prevSchema: TypeOf<typeof singlestoreSchema>,
) {
const suggestions: string[] = [];
const usedSuggestions: string[] = [];
const suggestionTypes = {
// TODO: Check if SingleStore has serial type
serial: withStyle.errorWarning(
`We deprecated the use of 'serial' for SingleStore starting from version 0.20.0. In SingleStore, 'serial' is simply an alias for 'bigint unsigned not null auto_increment unique,' which creates all constraints and indexes for you. This may make the process less explicit for both users and drizzle-kit push commands`,
),
};

for (const table of Object.values(curSchema.tables)) {
for (const column of Object.values(table.columns)) {
if (column.type === 'serial') {
if (!usedSuggestions.includes('serial')) {
suggestions.push(suggestionTypes['serial']);
}

const uniqueForSerial = Object.values(
prevSchema.tables[table.name].uniqueConstraints,
).find((it) => it.columns[0] === column.name);

suggestions.push(
`\n`
+ withStyle.suggestion(
`We are suggesting to change ${
chalk.blue(
column.name,
)
} column in ${
chalk.blueBright(
table.name,
)
} table from serial to bigint unsigned\n\n${
chalk.blueBright(
`bigint("${column.name}", { mode: "number", unsigned: true }).notNull().autoincrement().unique(${
uniqueForSerial?.name ? `"${uniqueForSerial?.name}"` : ''
})`,
)
}`,
),
);
}
}
}

return suggestions;
}

// Intersect with prepareAnMigrate
export const prepareSingleStorePush = async (
schemaPath: string | string[],
Expand Down

0 comments on commit 8084ad6

Please sign in to comment.