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

What's open-source commenting system are available? [closed]
CodeIgniter Encryption Class - How do I?
WHERE id IN doesn't work in UPDATE
Integrating Smarty into Zend Framework 1.10
Finding part of a string that a user has sent via POST
Form Submitting Incorrect Information to MySQL Database
How to pair users? (Like Omegle.com)
MySQL Insert Data Question
PDOStatement to json
How to populate html combo box with mysql data
Retrieving the CURL authentication server-side
php array into mysql
BSE/NSE quote in PHP [closed]
php how do I grab the date of oldest item in rss feed
Sorting an array into a multidimensional array based on “parent_id”
Get value of input box, without a form?

Categories

HOME
mpdf
apple-push-notifications
vagrant
plpgsql
moodle-api
flurry
sympy
azure-graph-api
migrate
business-intelligence
fullcalendar-scheduler
grocery-crud
createjs
bundler
xbox360
global-variables
asciimath
pickle
checkout
clr
vuforia
crud
list-comprehension
marquee
macromedia
php-5.3
unmarshalling
monitor
matlab-app-designer
windows2012
series
adminer
keyboard-layout
aurelia-http-client
recovery
gitolite
right-click
angular-datatables
common-table-expression
wysihtml5
directwrite
image-registration
non-linear-regression
amazon-elastic-beanstalk
android-webservice
scala-collections
connect-direct
gmaps.js
nitrousio
oid
gapi
nsrunloop
system.net.mail
android-syncadapter
accessibilityservice
univocity
management-studio-express
blockquote
roxygen2
textscan
abstract-factory
clarion
mgwt
tidyr
fat32
flurry-analytics
dmake
storing-data
category-theory
network-printers
lync-2010
strdup
particle-swarm
ctp
application-server
unrealscript
quickgraph
.net-remoting
notin
icenium
xalan
daap
clrprofiler
msinfo32
telerik-ajax
kolite
mvcrecaptcha
zend-server-ce
dynamic-c
snackjs
firefly-mv
page-curl
nsconnection
git-log
solandra
aspbutton
.net-services
zend-test
rakudo
server-load
webclient.uploaddata

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App