Xethron / migrations-generator

Laravel Migrations Generator: Automatically generate your migrations from an existing database schema.
MIT License
3.33k stars 586 forks source link

boolean field is not migrated properly #31

Closed rebin closed 7 years ago

rebin commented 10 years ago

I have a table with boolean field with default value set as false. When I run migration it shows $table->boolean('deleted')->default(''); default is shown as null field. Can you please check and let me know a solution for same

tomzx commented 10 years ago

Hi @rebin,

Could you provide the CREATE TABLE statement of the table that is causing this issue?

Also, this is a duplicate of #26.

rebin commented 10 years ago

Schema::create('vessel', function(Blueprint $table) { $table->bigInteger('id', true); $table->string('vessel_name', 50); $table->string('imo', 15)->nullable(); $table->bigInteger('vessel_type_id'); $table->bigInteger('shipping_agent_id')->nullable(); $table->bigInteger('shipping_line_id')->nullable(); $table->bigInteger('flag_id'); $table->string('call_sign', 7); $table->string('mmsi', 9)->nullable(); $table->decimal('loa', 6, 3); $table->decimal('beam', 4)->nullable(); $table->decimal('air_draught', 4)->nullable(); $table->string('photo_url')->nullable(); $table->boolean('deleted')->default(''); $table->bigInteger('user_id'); $table->timestamps(); $table->char('profile_status')->default('B'); });

On Mon, Oct 6, 2014 at 6:57 PM, tomzx notifications@github.com wrote:

Hi @rebin https://github.com/rebin,

Could you provide the CREATE TABLE statement of the table that is causing this issue?

— Reply to this email directly or view it on GitHub https://github.com/Xethron/migrations-generator/issues/31#issuecomment-58016294 .

rebin commented 10 years ago

$table->boolean('deleted')->default(''); is set to null here but in table it is flase. Create script from pgadmin deleted boolean NOT NULL DEFAULT false, -- Active / Inactive

On Wed, Oct 8, 2014 at 1:51 PM, Rebin K Joseph rebinkjoseph@gmail.com wrote:

Schema::create('vessel', function(Blueprint $table) { $table->bigInteger('id', true); $table->string('vessel_name', 50); $table->string('imo', 15)->nullable(); $table->bigInteger('vessel_type_id'); $table->bigInteger('shipping_agent_id')->nullable(); $table->bigInteger('shipping_line_id')->nullable(); $table->bigInteger('flag_id'); $table->string('call_sign', 7); $table->string('mmsi', 9)->nullable(); $table->decimal('loa', 6, 3); $table->decimal('beam', 4)->nullable(); $table->decimal('air_draught', 4)->nullable(); $table->string('photo_url')->nullable(); $table->boolean('deleted')->default(''); $table->bigInteger('user_id'); $table->timestamps(); $table->char('profile_status')->default('B'); });

On Mon, Oct 6, 2014 at 6:57 PM, tomzx notifications@github.com wrote:

Hi @rebin https://github.com/rebin,

Could you provide the CREATE TABLE statement of the table that is causing this issue?

— Reply to this email directly or view it on GitHub https://github.com/Xethron/migrations-generator/issues/31#issuecomment-58016294 .

tomzx commented 10 years ago

Hello again @rebin,

Sorry, I meant to ask for the SQL CREATE TABLE statement, not the php code.

CREATE TABLE `vessel` (
`id` int(10) unsigned not null auto_increment,
...
);
rebin commented 10 years ago

Ohh sorry, Here is the script. I use PostreSQL

CREATE TABLE vessel ( id bigint NOT NULL DEFAULT nextval('vessel_vessel_id_seq'::regclass), vessel_name character varying(50) NOT NULL, imo character varying(15), -- Every vessel will have a unique IMO number. The label begins with the letters "IMO" followed by either "Company" or "Registered Owner", then, followed by the seven digits. vessel_type_id bigint NOT NULL, -- vessel type master shipping_agent_id bigint, shipping_line_id bigint, flag_id bigint NOT NULL, -- countries master call_sign character varying(7) NOT NULL, mmsi character varying(9), loa numeric(6,3) NOT NULL, beam numeric(4,2), air_draught numeric(4,2), photo_url character varying(255), deleted boolean NOT NULL DEFAULT false, -- Active / Inactive user_id bigint NOT NULL, created_at timestamp(6) without time zone NOT NULL, updated_at timestamp(6) without time zone NOT NULL, profile_status character(1) NOT NULL DEFAULT 'B'::bpchar, -- Bacic or Completed. Use B for Basic anc C if profile saved completely CONSTRAINT vessel_pkey PRIMARY KEY (id) )

On Wed, Oct 8, 2014 at 6:06 PM, tomzx notifications@github.com wrote:

Hello again @rebin https://github.com/rebin,

Sorry, I meant to ask for the SQL CREATE TABLE statement, not the php code.

CREATE TABLE vessel ( id int(10) unsigned not null auto_increment, ... );

— Reply to this email directly or view it on GitHub https://github.com/Xethron/migrations-generator/issues/31#issuecomment-58350502 .

jpcaparas commented 8 years ago

Same issue I have with a postgres db

Xethron commented 8 years ago

Seems to be related to #79 and #83

Xethron commented 7 years ago

Fixed :)