Closed flik closed 5 years ago
Thank you for your reporting errors. I will check this error.
If you can, tell me your development environment as detailed as possible. And give me your crud-d-scaffold.json file.
{ "app_type": "web", "use_laravel_auth": false, "models": [ { "id": 1, "name": "nicePost", "display_name": "NICE POST", "use_soft_delete": true, "schemas": [ { "id": 1, "name": "bigTitle", "display_name": "BIG TITLE", "type": "string", "input_type": "text", "varidate": "", "faker_type": "name()", "nullable": false, "unique": false, "show_in_list": true, "show_in_detail": true, "belongsto": "", "parent_id": 1 }, { "id": 2, "name": "shallowBody", "display_name": "SHALLOW BODY", "type": "string", "input_type": "textarea", "varidate": "", "faker_type": "paragraph()", "nullable": false, "unique": false, "show_in_list": false, "show_in_detail": true, "belongsto": "", "parent_id": 1 }, { "id": 3, "name": "brilliantCategory_id", "display_name": "brilliantCategory - NAME", "type": "integer", "input_type": "select", "varidate": "", "faker_type": "numberBetween(1,30)", "nullable": true, "unique": false, "show_in_list": true, "show_in_detail": true, "belongsto": "brilliantCategory", "parent_id": 1 } ], "is_pivot": false, "schema_id_for_relation": 1, "pos_x": 707, "pos_y": 347, "_next_schema_id": 4 }, { "id": 2, "name": "beautifulTag", "display_name": "TAG", "use_soft_delete": true, "schemas": [ { "id": 1, "name": "tagName", "display_name": "TAG NAME", "type": "string", "input_type": "text", "varidate": "", "faker_type": "name()", "nullable": false, "unique": false, "show_in_list": true, "show_in_detail": true, "belongsto": "", "parent_id": 2 } ], "is_pivot": false, "schema_id_for_relation": 1, "pos_x": 1357, "pos_y": 158, "_next_schema_id": 2 }, { "id": 3, "name": "brilliantCategory", "display_name": "CATEGORY", "use_soft_delete": true, "schemas": [ { "id": 1, "name": "categoryName", "display_name": "CATEGORY NAME", "type": "string", "input_type": "text", "varidate": "", "faker_type": "name()", "nullable": false, "unique": false, "show_in_list": true, "show_in_detail": true, "belongsto": "", "parent_id": 3 } ], "is_pivot": false, "schema_id_for_relation": 1, "pos_x": 486, "pos_y": 76, "_next_schema_id": 2 }, { "id": 4, "name": "goodComment", "display_name": "GOOD COMMENT", "use_soft_delete": true, "schemas": [ { "id": 1, "name": "superTitle", "display_name": "SUPER TITLE", "type": "string", "input_type": "text", "varidate": "", "faker_type": "name()", "nullable": false, "unique": false, "show_in_list": true, "show_in_detail": true, "belongsto": "", "parent_id": 4 }, { "id": 2, "name": "eligibleBody", "display_name": "ELIGIBLE BODY", "type": "string", "input_type": "textarea", "varidate": "", "faker_type": "paragraph()", "nullable": false, "unique": false, "show_in_list": false, "show_in_detail": true, "belongsto": "", "parent_id": 4 }, { "id": 3, "name": "nicePost_id", "display_name": "nicePost - NAME", "type": "integer", "input_type": "select", "varidate": "", "faker_type": "numberBetween(1,30)", "nullable": true, "unique": false, "show_in_list": true, "show_in_detail": true, "belongsto": "nicePost", "parent_id": 4 } ], "is_pivot": false, "schema_id_for_relation": 1, "pos_x": 1014, "pos_y": 633, "_next_schema_id": 4 }, { "id": 5, "name": "beautifulTag_nicePost", "display_name": "PIVOT", "use_soft_delete": true, "schemas": [ { "id": 1, "name": "beautifulTag_id", "display_name": "beautifulTag - NAME", "type": "integer", "input_type": "select", "varidate": "", "faker_type": "numberBetween(1,30)", "nullable": true, "unique": false, "show_in_list": true, "show_in_detail": true, "belongsto": "beautifulTag", "parent_id": 5 }, { "id": 2, "name": "nicePost_id", "display_name": "nicePost - NAME", "type": "integer", "input_type": "select", "varidate": "", "faker_type": "numberBetween(1,30)", "nullable": true, "unique": false, "show_in_list": true, "show_in_detail": true, "belongsto": "nicePost", "parent_id": 5 }, { "id": 3, "name": "priority", "display_name": "PRIORITY", "type": "integer", "input_type": "text", "varidate": "", "faker_type": "numberBetween(1,10)", "nullable": true, "unique": false, "show_in_list": true, "show_in_detail": true, "belongsto": "", "parent_id": 5 }, { "id": 4, "name": "note", "display_name": "NOTE", "type": "string", "input_type": "text", "varidate": "", "faker_type": "name()", "nullable": true, "unique": false, "show_in_list": true, "show_in_detail": true, "belongsto": "", "parent_id": 5 } ], "is_pivot": true, "schema_id_for_relation": 0, "pos_x": 1030, "pos_y": 147, "_next_schema_id": 5 } ], "tool": "ER-DIAGRAM-TOOL", "_next_model_id": 6 }
.env
`APP_NAME=Laravel APP_ENV=local APP_KEY=base64:ee1y2CIdmhyaoj0SSvYgrpQJRm/UfZGSlPfROUDKkuM= APP_DEBUG=true APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=xxxx DB_USERNAME=xxxx DB_PASSWORD=xxxx
BROADCAST_DRIVER=log CACHE_DRIVER=file QUEUE_CONNECTION=sync SESSION_DRIVER=file SESSION_LIFETIME=120
REDIS_HOST=127.0.0.1 REDIS_PASSWORD=null REDIS_PORT=6379
MAIL_DRIVER=smtp MAIL_HOST=smtp.mailtrap.io MAIL_PORT=2525 MAIL_USERNAME=null MAIL_PASSWORD=null MAIL_ENCRYPTION=null
AWS_ACCESS_KEY_ID= AWS_SECRET_ACCESS_KEY= AWS_DEFAULT_REGION=us-east-1 AWS_BUCKET=
PUSHER_APP_ID= PUSHER_APP_KEY= PUSHER_APP_SECRET= PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" `
Thank you.
I see why this error occured. In creating foreign key constraints, original table and target table must be created.
I'll try to debug this error in a few weeks. Please wait for a while.
To flik.
I modified my package. Please try to use my package again.
If error is occured again, tell me.
Hi, thanks for update and help. Now, I updated the composer with update command then I rollback all migrations and then and started again and get this response:
`$ php artisan migrate Migrating: 2014_10_12_000000_create_users_table Migrated: 2014_10_12_000000_create_users_table Migrating: 2014_10_12_100000_create_password_resets_table Migrated: 2014_10_12_100000_create_password_resets_table Migrating: 2019_05_07_044542_add_column_to_users_table
Illuminate\Database\QueryException : SQLSTATE[HY000]: General error: 1005 Can't create table ad vert
.#sql-2670_5
(errno: 150 "Foreign key constraint is incorrectly formed") (SQL: alter table u sers
add constraint users_company_id_foreign
foreign key (company_id
) references companies
( id
))
at D:\xampp\htdocs\advert\vendor\laravel\framework\src\Illuminate\Database\Connection.php:664 660| // If an exception occurs when attempting to run a query, we'll format the error 661| // message to include the bindings with SQL, which will make this exception a 662| // lot more helpful to the developer instead of just the database's errors. 663| catch (Exception $e) {
664| throw new QueryException( 665| $query, $this->prepareBindings($bindings), $e 666| ); 667| } 668|
Exception trace:
1 PDOException::("SQLSTATE[HY000]: General error: 1005 Can't create table advert
.#sql-2670_5
(errno: 150 "Foreign key constraint is incorrectly formed")")
D:\xampp\htdocs\advert\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458
2 PDOStatement::execute() D:\xampp\htdocs\advert\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458
Please use the argument -v to see more details. `
Here is json file:
{ "app_type": "web", "use_laravel_auth": true, "models": [ { "id": 1, "name": "user", "display_name": "USER", "use_soft_delete": false, "schemas": [ { "id": 1, "name": "name", "display_name": "NAME", "type": "string", "input_type": "text", "varidate": "", "faker_type": "name()", "nullable": false, "unique": false, "show_in_list": true, "show_in_detail": true, "belongsto": "", "parent_id": 1 }, { "id": 2, "name": "email", "display_name": "EMAIL", "type": "string", "input_type": "text", "varidate": "", "faker_type": "unique()->safeEmail()", "nullable": false, "unique": true, "show_in_list": false, "show_in_detail": true, "belongsto": "", "parent_id": 1 }, { "id": 3, "name": "password", "display_name": "PASSWORD", "type": "string", "input_type": "password", "varidate": "", "faker_type": "password()", "nullable": false, "unique": false, "show_in_list": false, "show_in_detail": false, "belongsto": "", "parent_id": 1 }, { "id": 4, "name": "birthDay", "display_name": "BIRTH DAY", "type": "string", "input_type": "text", "varidate": "", "faker_type": "date()", "nullable": true, "unique": false, "show_in_list": true, "show_in_detail": true, "belongsto": "", "parent_id": 1 }, { "id": 5, "name": "phone", "display_name": "PHONE", "type": "string", "input_type": "text", "varidate": "", "faker_type": "phoneNumber()", "nullable": true, "unique": false, "show_in_list": false, "show_in_detail": true, "belongsto": "", "parent_id": 1 }, { "id": 6, "name": "company_id", "display_name": "company - NAME", "type": "integer", "input_type": "select", "varidate": "", "faker_type": "numberBetween(1,30)", "nullable": true, "unique": false, "show_in_list": true, "show_in_detail": true, "belongsto": "company", "parent_id": 1 } ], "is_pivot": false, "schema_id_for_relation": 1, "pos_x": 901, "pos_y": 101, "_next_schema_id": 7 }, { "id": 2, "name": "company", "display_name": "COMPANY", "use_soft_delete": true, "schemas": [ { "id": 1, "name": "name", "display_name": "NAME", "type": "string", "input_type": "text", "varidate": "", "faker_type": "company()", "nullable": false, "unique": false, "show_in_list": true, "show_in_detail": true, "belongsto": "", "parent_id": 2 } ], "is_pivot": false, "schema_id_for_relation": 1, "pos_x": 587, "pos_y": 35, "_next_schema_id": 2 }, { "id": 3, "name": "hobby", "display_name": "HOBBY", "use_soft_delete": true, "schemas": [ { "id": 1, "name": "name", "display_name": "NAME", "type": "string", "input_type": "text", "varidate": "", "faker_type": "word()", "nullable": false, "unique": false, "show_in_list": true, "show_in_detail": true, "belongsto": "", "parent_id": 3 } ], "is_pivot": false, "schema_id_for_relation": 1, "pos_x": 1584, "pos_y": 143, "_next_schema_id": 2 }, { "id": 4, "name": "dog", "display_name": "DOG", "use_soft_delete": true, "schemas": [ { "id": 1, "name": "name", "display_name": "NAME", "type": "string", "input_type": "text", "varidate": "", "faker_type": "name()", "nullable": false, "unique": false, "show_in_list": true, "show_in_detail": true, "belongsto": "", "parent_id": 4 }, { "id": 2, "name": "weight", "display_name": "WEIGHT", "type": "integer", "input_type": "text", "varidate": "", "faker_type": "numberBetween(1,10)", "nullable": false, "unique": false, "show_in_list": false, "show_in_detail": true, "belongsto": "", "parent_id": 4 }, { "id": 3, "name": "user_id", "display_name": "user - NAME", "type": "integer", "input_type": "select", "varidate": "", "faker_type": "numberBetween(1,30)", "nullable": true, "unique": false, "show_in_list": true, "show_in_detail": true, "belongsto": "user", "parent_id": 4 } ], "is_pivot": false, "schema_id_for_relation": 1, "pos_x": 1153, "pos_y": 436, "_next_schema_id": 4 }, { "id": 5, "name": "hobby_user", "display_name": "PIVOT", "use_soft_delete": true, "schemas": [ { "id": 1, "name": "hobby_id", "display_name": "hobby - NAME", "type": "integer", "input_type": "select", "varidate": "", "faker_type": "numberBetween(1,30)", "nullable": true, "unique": false, "show_in_list": true, "show_in_detail": true, "belongsto": "hobby", "parent_id": 5 }, { "id": 2, "name": "user_id", "display_name": "user - NAME", "type": "integer", "input_type": "select", "varidate": "", "faker_type": "numberBetween(1,30)", "nullable": true, "unique": false, "show_in_list": true, "show_in_detail": true, "belongsto": "user", "parent_id": 5 }, { "id": 3, "name": "skillLevel", "display_name": "SKILL LEVEL", "type": "integer", "input_type": "text", "varidate": "", "faker_type": "numberBetween(1,30)", "nullable": true, "unique": false, "show_in_list": true, "show_in_detail": true, "belongsto": "", "parent_id": 5 }, { "id": 4, "name": "firendName", "display_name": "FRIEND NAME", "type": "string", "input_type": "text", "varidate": "", "faker_type": "name()", "nullable": false, "unique": false, "show_in_list": false, "show_in_detail": true, "belongsto": "", "parent_id": 5 } ], "is_pivot": true, "schema_id_for_relation": 0, "pos_x": 1246, "pos_y": 41, "_next_schema_id": 5 } ], "tool": "ER-DIAGRAM-TOOL", "_next_model_id": 6 }
Okey. package update and reset migration is not enough to fix this error. You have to execute command "php artisan crud-d-scaffold:setup -f" to generate migration files again. Could you re-install Laravel and install package with readme.
Kind regards
ok. let me do it.
Now, I have reinstalled everything and now here is some output : ` php artisan migrate:rollback Rolling back: 2014_10_12_100000_create_password_resets_table Rolled back: 2014_10_12_100000_create_password_resets_table Rolling back: 2014_10_12_000000_create_users_table Rolled back: 2014_10_12_000000_create_users_table
xAdmin@DESKTOP-CV23NAQ MINGW64 /d/xampp/htdocs/advert $ php artisan crud-d-scaffold:setup -f Load Data... reading setting file... (crud-d-scaffold.json) Now Generating... Dump-autoload... Configuring is done
xAdmin@DESKTOP-CV23NAQ MINGW64 /d/xampp/htdocs/advert $ php artisan migrate PHP Fatal error: Cannot declare class AddColumnToUsersTable, because the name is already in use in D:\xampp\htdocs\advert\databa se\migrations\2019_05_07_112120_add_column_to_users_table.php on line 36
Symfony\Component\Debug\Exception\FatalErrorException : Cannot declare class AddColumnToUsersTable, because the name is alrea dy in use
at D:\xampp\htdocs\advert\database\migrations\2019_05_07_112120_add_column_to_users_table.php:36 32| @return void 33| / 34| public function down() 35| {}
36| }
Whoops\Exception\ErrorException : Cannot declare class AddColumnToUsersTable, because the name is already in use
at D:\xampp\htdocs\advert\database\migrations\2019_05_07_112120_add_column_to_users_table.php:36 32| @return void 33| / 34| public function down() 35| {}
36| }
`
ok. I will check again. please wait for a few days.
Hi, flik Thank you for waiting.
I update my package.
Could you re-install Laravel and install package and put crud-d-scaffold.json file. And execute command
php artisan make:auth php artisan crud-d-scaffold:setup -f php artisan migrate php artisan db:seed
Let me add some notes.
If you get error "Data too long for column..." in seeding, edit crud-d-scaffold.json as follow.
[as is] { "id": 2, "name": "shallowBody", "display_name": "SHALLOW BODY", "type": "string", "input_type": "textarea", [to be] { "id": 2, "name": "shallowBody", "display_name": "SHALLOW BODY", "type": "text", "input_type": "textarea",
[as is] { "id": 2, "name": "eligibleBody", "display_name": "ELIGIBLE BODY", "type": "string", "input_type": "textarea", "varidate" [to be] { "id": 2, "name": "eligibleBody", "display_name": "ELIGIBLE BODY", "type": "text", "input_type": "textarea", "varidate"
This issue is modified.
I have tried all steps successfully at the end Now getting this exception may you can help...