laravel-migrations

Artisan, creating tables in database

五迷三道 提交于 2019-12-03 06:40:33
问题 I am trying to create mysql tables in Laravel 5. I created a file in /project/database/migrations called users.php : [...] public function up() { Schema::create('users', function(Blueprint $table) { $table->increments('id'); $table->string('username'); $table->string('fullname'); $table->int('number'); $table->string('email')->unique(); $table->string('password', 60); $table->rememberToken(); $table->timestamps(); }); } [...] I then tried running these commands in the project -folder: $ php

How to convert Laravel migrations to raw SQL scripts?

99封情书 提交于 2019-12-03 02:44:22
问题 Developers of my team are really used to the power of Laravel migrations, they are working great on local machines and our dev servers. But customer's database admin will not accept Laravel migrations. He asks for raw SQL scripts for each new version of our application. Is there any tool or programming technique to capture the output from Laravel migrations to up/down SQL scripts? It would be perfect if we could integrate SQL script generation in our CI system (TeamCity) when creating

Artisan, creating tables in database

廉价感情. 提交于 2019-12-02 20:19:09
I am trying to create mysql tables in Laravel 5. I created a file in /project/database/migrations called users.php : [...] public function up() { Schema::create('users', function(Blueprint $table) { $table->increments('id'); $table->string('username'); $table->string('fullname'); $table->int('number'); $table->string('email')->unique(); $table->string('password', 60); $table->rememberToken(); $table->timestamps(); }); } [...] I then tried running these commands in the project -folder: $ php artisan migrate $ php artisan migrate:install $ php artisan migrate --pretend None of them return any

Laravel Unknown Column 'updated_at'

99封情书 提交于 2019-11-28 15:18:02
问题 I've just started with Laravel and I get the following error: Unknown column 'updated_at' insert into gebruikers (naam, wachtwoord, updated_at, created_at) I know the error is from the timestamp column when you migrate a table but I'm not using the updated_at field. I used to use it when I followed the Laravel tutorial but now that I am making (or attempting to make) my own stuff. I get this error even though I don't use timestamps. I can't seem to find the place where it's being used. This

Database gets stuck in migration with seeder on production with --force in Laravel 5

 ̄綄美尐妖づ 提交于 2019-11-28 05:42:18
问题 Database gets stuck in migration with seeder on production with --force in Laravel. Same effect I have on Laravel Homestead and EC2 AWS running Amazone linux. No messages in laravel.log. It just never ends. If I halt it with <ctrl>+<c> , I see the table created but seeder was not run, the table is empty. Detalis: My migration: public function up() { Schema::create('products', function (Blueprint $table) { $table->increments('id'); $table->string('name', 50); $table->decimal('price', 8, 2); /

Laravel migration - Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails

醉酒当歌 提交于 2019-11-28 03:19:34
问题 I am trying to run a migration for a table inventories that I have created with this migration: Schema::create('inventories', function (Blueprint $table) { $table->increments('id'); $table->integer('remote_id')->unsigned(); $table->integer('local_id')->unsigned(); $table->string('local_type'); $table->string('url')->nullable()->unique(); $table->timestamps(); }); I am trying to add a run a migration where I am adding a foreign key to the table: Schema::table('inventories', function (Blueprint

Laravel Migration Change to Make a Column Nullable

风格不统一 提交于 2019-11-28 03:02:51
I created a migration with unsigned user_id . How can I edit user_id in a new migration to also make it nullable() ? Schema::create('throttle', function(Blueprint $table) { $table->increments('id'); // this needs to also be nullable, how should the next migration be? $table->integer('user_id')->unsigned(); } Laravel 5 now supports changing column.. Example from offical doc Schema::table('users', function($table) { $table->string('name', 50)->nullable()->change(); }); source: http://laravel.com/docs/5.0/schema#changing-columns Laravel 4 does not support to modify column. You have to write raw

How do Laravel migrations work?

牧云@^-^@ 提交于 2019-11-27 23:49:17
问题 I'm totally new to this type of framework. I've come from barebones PHP development and I can't seem to find an easy to understand guide what migrations actually do. I'm trying to create a project that already has an existing database. I've used this: https://github.com/Xethron/migrations-generator[1] but making changes to the schema via the migrations seems to spit out errors which means I have no idea what I'm doing. I really need a simple run down of what migrations actually do, how they

Add a new column to existing table in a migration

本秂侑毒 提交于 2019-11-27 05:47:51
I can't figure out how to add a new column to my existing database table using the Laravel framework. I tried to edit the migration file using... <?php public function up() { Schema::create('users', function ($table) { $table->integer("paid"); }); } In terminal, I execute php artisan migrate:install and migrate . How do I add new columns? Phill Sparks To create a migration, you may use the migrate:make command on the Artisan CLI. Use a specific name to avoid clashing with existing models for Laravel 3: php artisan migrate:make add_paid_to_users for Laravel 5+: php artisan make:migration add

Laravel Migration Change to Make a Column Nullable

喜你入骨 提交于 2019-11-26 23:54:41
问题 I created a migration with unsigned user_id . How can I edit user_id in a new migration to also make it nullable() ? Schema::create('throttle', function(Blueprint $table) { $table->increments('id'); // this needs to also be nullable, how should the next migration be? $table->integer('user_id')->unsigned(); } 回答1: Laravel 5 now supports changing a column; here's an example from the offical documentation: Schema::table('users', function($table) { $table->string('name', 50)->nullable()->change()