Home / Function/ convert() — drizzle-orm Function Reference

convert() — drizzle-orm Function Reference

Architecture documentation for the convert() function in sqlgenerator.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  0877e1c9_cc6e_31fc_c17f_e4c4d4e82ac7["convert()"]
  6127d05d_f7e8_0317_b8fc_aa83bc4b3b6b["SqliteAlterTableAlterCompositePrimaryKeyConvertor"]
  0877e1c9_cc6e_31fc_c17f_e4c4d4e82ac7 -->|defined in| 6127d05d_f7e8_0317_b8fc_aa83bc4b3b6b
  style 0877e1c9_cc6e_31fc_c17f_e4c4d4e82ac7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-kit/src/sqlgenerator.ts lines 3223–3243

	convert(statement: JsonAlterCompositePK) {
		let msg = '/*\n';
		msg += 'SQLite does not support altering primary key\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

Subdomains

Frequently Asked Questions

What does convert() do?
convert() is a function in the drizzle-orm codebase, defined in drizzle-kit/src/sqlgenerator.ts.
Where is convert() defined?
convert() is defined in drizzle-kit/src/sqlgenerator.ts at line 3223.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free