diff --git a/models/Grammars/Grammar.cfc b/models/Grammars/Grammar.cfc index 83d81a95..1f26965e 100644 --- a/models/Grammars/Grammar.cfc +++ b/models/Grammars/Grammar.cfc @@ -779,6 +779,10 @@ component displayname="Grammar" accessors="true" { return "BIGINT"; } + function typeBit( column ) { + return "BIT(#column.getLength()#)"; + } + function typeBoolean( column ) { return "TINYINT(1)"; } diff --git a/models/Schema/Blueprint.cfc b/models/Schema/Blueprint.cfc index 78a05b0e..5be10f7a 100644 --- a/models/Schema/Blueprint.cfc +++ b/models/Schema/Blueprint.cfc @@ -65,6 +65,11 @@ component accessors="true" { return addColumn( argumentCollection = arguments ); } + function bit( name, length = 1 ) { + arguments.type = "bit"; + return addColumn( argumentCollection = arguments ); + } + function boolean( name ) { arguments.length = 1; arguments.type = "boolean"; diff --git a/tests/specs/Schema/SchemaBuilder+GrammarSpec.cfc b/tests/specs/Schema/SchemaBuilder+GrammarSpec.cfc index ef8bb2d3..218258c3 100644 --- a/tests/specs/Schema/SchemaBuilder+GrammarSpec.cfc +++ b/tests/specs/Schema/SchemaBuilder+GrammarSpec.cfc @@ -50,6 +50,22 @@ component extends="testbox.system.BaseSpec" { expect( blueprint.toSql() ).toBeWithCase( "CREATE TABLE ""weather_reports"" (""temperature"" BIGINT NOT NULL)" ); } ); + it( "bit", function() { + var schema = getBuilder(); + var blueprint = schema.create( "users", function( table ) { + table.bit( "active" ); + }, false ); + expect( blueprint.toSql() ).toBeWithCase( "CREATE TABLE ""users"" (""active"" BIT(1) NOT NULL)" ); + } ); + + it( "bit (with length)", function() { + var schema = getBuilder(); + var blueprint = schema.create( "users", function( table ) { + table.bit( "something", 4 ); + }, false ); + expect( blueprint.toSql() ).toBeWithCase( "CREATE TABLE ""users"" (""something"" BIT(4) NOT NULL)" ); + } ); + it( "boolean", function() { var schema = getBuilder(); var blueprint = schema.create( "users", function( table ) {