php


laravel migration creates different schema


I was watching a tutorial from Laracast titles "Laracast Digging In" and the first part illustrates how to use eloquent simply by doing.
# app/models/tasks.php
class tasks extends Eloquent{
}
then goes on to do
php artisan migration:make create_tasks_table --create --table="tasks"
Then a migration file is made that looks like this.
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTasksTable extends Migration {
/**
* Run the migrations.
*
* #return void
*/
public function up()
{
Schema::create("tasks", function(Blueprint $table)
{
$table->increments("id");
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* #return void
*/
public function down()
{
Schema::drop("tasks");
}
}
While I do exactly the same, I am getting slightly a different result.
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTasksTable extends Migration {
/**
* Run the migrations.
*
* #return void
*/
public function up()
{
Schema::table('tasks', function(Blueprint $table)
{
//
});
}
/**
* Reverse the migrations.
*
* #return void
*/
public function down()
{
Schema::table('tasks', function(Blueprint $table)
{
//
});
}
}
As you can see, aside my approach omitting
$table->increments("id");
$table->timestamps();
It has entirely replaced create with table here.
Schema::table('tasks', function(Blueprint $table)
^^ is 'create' in the tutorial.
Why, is this happening. If I simply ignore this and start following the tutorial I can't get anything to work. And I don't want to modify this by hand, so why is this happening and how do I solve it.
You are using the command wrong
Based on Laravel tutorial
use this :
For creating a table
php artisan migrate:make create_tasks_table --create=tasks
For updating a table
php artisan migrate:make create_tasks_table --table=tasks
Basically you need to use --create OR --table not both.
when you are using --create , then the migration will be with Schema::create indicating that the migration will create a table
when you are using --table , then the migration will be Schema::table indicating that a table will be updated
Use either --table="tableName" (Schema::table) for updating your table or --create="tableName" (Schema::create) for creating a new one.
I'm pretty sure in the tutorial you followed, the developper used
JeffreyWay/Laravel-4-Generators.
utill you feel confortable with Laravel4, ignore the generator and replace 'table' by create or drop according to the action you want to execute.
Sorry for my bad english

Related Links

how to manuplate the google api php client
Unable to get cookie in construct function
How to loop through Models find from Where clause?
Trying to keep session with curl login in twitter
Code start and end in specific time
Return total values of each column after using datepicker to select a start and end date
file_put_contents on multiple request of XML data
How can i change this select sql statement into another select sql?
This code always return $id but not $first_name [duplicate]
Laravel 5.3 array validation
recursion - How to construct a data tree without ids, data is ambigious.
Submitting a form at 3 different times using PHP
How to share a Laravel app codebase in a Docker container while preserving permissions?
PHP: CSV import into MYSQL is always less than the actual amount of rows in the CSV file?
WP template code runs before action
Set expiry time for laravel jwt dynamically

Categories

HOME
openshift
angular-ui-grid
yahoo-weather-api
whmcs
semantic-web
impala
capistrano
angular-meteor
javafx-8
firebase-dynamic-links
selection
gtk
game-maker
clish
business-intelligence
sslhandshakeexception
synthesis
temperature
android-5.1.1-lollipop
hidden
pickle
varnish-vcl
salt-cloud
nullreferenceexception
scheduled-tasks
clr
angular2-highcharts
multi-upload
software-packaging
points
oracleforms
dnsmasq
docx4j
copy-protection
nsmutablearray
orchardcms-1.8
ftp-server
identify
text-decorations
suds
jacoco-maven-plugin
vungle-ads
audio-converter
music21
intellij-lombok-plugin
sequence-diagram
sesame
predicates
swiperefreshlayout
nitrousio
gawk
pjax
java-2d
xcode6.4
logical
openquery
system.web.optimization
visual-studio-monaco
p6spy
seccomp
callouts
jemdoc
gridbaglayout
gdl
deeplink
fanotify
enaml
blockquote
baseadapter
sql-processor
xml-signature
inequality
ecos
commenting
tabletools
illuminate-container
mute
yii-booster
ax
node.js-stream
lynx
first-class
hardcode
uploading
wiktionary
quartz-core
zend-server-ce
vows
net-use
asp.net-mvc-views
ccl
tessellation
icicles
fxruby
rtti
autobench
rakudo

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App