• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to create more than 1 table in Migration?

I followed the guideline here: 

Database Manipulation and Database Forge

I managed to run the migration, and successfully created 1 table with necessary fields.
All files are duly placed inside app/Database/Migrations.

So my questions right now are;
1. How to create more than 1 table? (in just 1 Migration file)
2. What is really up() and down() for? (is it a must? can I write a custom method instead?) 

Thank you.


You just continue on like you did the first one repeating for all the tables you need

Add fields
Add Keys
Create table

Add fields
Add Keys
Create table

List of tables

Like so.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )

Yes, migrations can do multiple DB modifications (add tables, drop tables, add indexes, etc).

It is not considered bad form. Migration is a collection of steps necessary to upgrade/downgrade your database to the next/previous format, respectively

Schema::create('users', function($table)

Schema::create('rights', function($table)

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.