diff --git a/vendor/wheels/databaseAdapters/CockroachDB/CockroachDBMigrator.cfc b/vendor/wheels/databaseAdapters/CockroachDB/CockroachDBMigrator.cfc index 805e8dd536..6714fe046b 100644 --- a/vendor/wheels/databaseAdapters/CockroachDB/CockroachDBMigrator.cfc +++ b/vendor/wheels/databaseAdapters/CockroachDB/CockroachDBMigrator.cfc @@ -7,4 +7,16 @@ component extends="wheels.databaseAdapters.PostgreSQL.PostgreSQLMigrator" { return "CockroachDB"; } + /** + * generates sql for primary key options + * CockroachDB does not support SERIAL; use INT DEFAULT unique_rowid() instead + */ + public string function addPrimaryKeyOptions(required string sql, struct options = {}) { + if (StructKeyExists(arguments.options, "autoIncrement") && arguments.options.autoIncrement) { + arguments.sql = ReplaceNoCase(arguments.sql, "INTEGER", "INT DEFAULT unique_rowid()", "all"); + } + arguments.sql = arguments.sql & " PRIMARY KEY"; + return arguments.sql; + } + }