SqliteAlterTableCreateCompositePrimaryKeyConvertor Class — drizzle-orm Architecture
Architecture documentation for the SqliteAlterTableCreateCompositePrimaryKeyConvertor class in sqlgenerator.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD fd7f48c8_e27a_7047_e96e_2180fd469b79["SqliteAlterTableCreateCompositePrimaryKeyConvertor"] fe4174c7_3b9c_5b26_98a0_b2395ca21939["sqlgenerator.ts"] fd7f48c8_e27a_7047_e96e_2180fd469b79 -->|defined in| fe4174c7_3b9c_5b26_98a0_b2395ca21939 07abf651_8d7a_e0a4_e764_6fde42277806["can()"] fd7f48c8_e27a_7047_e96e_2180fd469b79 -->|method| 07abf651_8d7a_e0a4_e764_6fde42277806 05245ff2_77d6_8967_71a2_b015cc5a8c66["convert()"] fd7f48c8_e27a_7047_e96e_2180fd469b79 -->|method| 05245ff2_77d6_8967_71a2_b015cc5a8c66
Relationship Graph
Source Code
drizzle-kit/src/sqlgenerator.ts lines 3163–3189
class SqliteAlterTableCreateCompositePrimaryKeyConvertor extends Convertor {
can(statement: JsonStatement, dialect: Dialect): boolean {
return statement.type === 'create_composite_pk' && dialect === 'sqlite';
}
convert(statement: JsonCreateCompositePK) {
let msg = '/*\n';
msg += `You're trying to add PRIMARY KEY(${statement.data}) to '${statement.tableName}' table\n`;
msg += 'SQLite does not support adding primary key to an already created table\n';
msg += 'You can do it in 3 steps with drizzle orm:\n';
msg += ' - create new mirror table with needed pk, rename current table to old_table, generate SQL\n';
msg += ' - migrate old data from one table to another\n';
msg += ' - delete old_table in schema, generate sql\n\n';
msg += 'or create manual migration like below:\n\n';
msg += 'ALTER TABLE table_name RENAME TO old_table;\n';
msg += 'CREATE TABLE table_name (\n';
msg += '\tcolumn1 datatype [ NULL | NOT NULL ],\n';
msg += '\tcolumn2 datatype [ NULL | NOT NULL ],\n';
msg += '\t...\n';
msg += '\tPRIMARY KEY (pk_col1, pk_col2, ... pk_col_n)\n';
msg += ' );\n';
msg += 'INSERT INTO table_name SELECT * FROM old_table;\n\n';
msg += "Due to that we don't generate migration automatically and it has to be done manually\n";
msg += '*/\n';
return msg;
}
}
Domain
Defined In
Source
Frequently Asked Questions
What is the SqliteAlterTableCreateCompositePrimaryKeyConvertor class?
SqliteAlterTableCreateCompositePrimaryKeyConvertor is a class in the drizzle-orm codebase, defined in drizzle-kit/src/sqlgenerator.ts.
Where is SqliteAlterTableCreateCompositePrimaryKeyConvertor defined?
SqliteAlterTableCreateCompositePrimaryKeyConvertor is defined in drizzle-kit/src/sqlgenerator.ts at line 3163.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free