You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+26-52Lines changed: 26 additions & 52 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,9 @@
9
9
10
10
Generate Laravel Migrations from an existing database, including indexes and foreign keys!
11
11
12
-
This package is a modified version of https://github.com/Xethron/migrations-generator that has been updated to support Laravel 5.6 and beyond, along with additional features.
12
+
## Documentation
13
+
14
+
Checkout the [documentation](https://kitloong.github.io/laravel-migrations-generator/usage/) for more details.
13
15
14
16
## Supported Database
15
17
@@ -80,7 +82,7 @@ You can also ignore tables with:
| -c, --connection[=CONNECTION]| The database connection to use |
110
-
| -t, --tables[=TABLES]| A list of tables or views you wish to generate migrations for separated by a comma: users,posts,comments |
111
-
| -i, --ignore[=IGNORE]| A list of tables or views you wish to ignore, separated by a comma: users,posts,comments |
112
-
| -p, --path[=PATH]| Where should the file be created? |
113
-
| -tp, --template-path[=TEMPLATE-PATH]| The location of the template for this generator |
114
-
| --date[=DATE]| Migrations will be created with specified date. Views and foreign keys will be created with + 1 second. Date should be in format supported by `Carbon::parse`|
| --log-with-batch[=LOG-WITH-BATCH]| Log migrations with given batch number. We recommend using batch number 0 so that it becomes the first migration |
120
-
| --default-index-names | Don\'t use DB index names for migrations |
121
-
| --default-fk-names | Don\'t use DB foreign key names for migrations |
122
-
| --use-db-collation | Generate migrations with existing DB collation |
| --squash | Generate all migrations into a single file |
128
-
| --with-has-table | Check for the existence of a table using `hasTable`|
129
-
130
-
## SQLite Alter Foreign Key
131
-
132
-
The generator first generates all tables and then adds foreign keys to existing tables.
133
-
134
-
However, SQLite only supports foreign keys upon creation of the table and not when tables are altered.
135
-
*_add_foreign_keys_* migrations will still be generated, however will get omitted if migrate to SQLite type database.
136
-
137
-
## User-Defined Type Columns
138
-
139
-
The generator will recognize user-defined type from the schema, and then generate migration as
140
-
141
-
```php
142
-
public function up()
143
-
{
144
-
Schema::create('table', function (Blueprint $table) {
145
-
...
146
-
});
147
-
DB::statement("ALTER TABLE table ADD column custom_type NOT NULL");
148
-
}
149
-
```
150
-
151
-
Note that the new `column` is always added at the end of the created `table` which means the ordering of the column generated in migration will differ from what we have from the schema.
|[-c, --connection[=CONNECTION]](https://kitloong.github.io/laravel-migrations-generator/options/connection/)| The database connection to use |
112
+
|[-t, --tables[=TABLES]](https://kitloong.github.io/laravel-migrations-generator/options/tables/)| A list of tables or views you wish to generate migrations for separated by a comma: users,posts,comments |
113
+
|[-i, --ignore[=IGNORE]](https://kitloong.github.io/laravel-migrations-generator/options/ignore/)| A list of tables or views you wish to ignore, separated by a comma: users,posts,comments |
114
+
|[-p, --path[=PATH]](https://kitloong.github.io/laravel-migrations-generator/options/path/)| Where should the file be created? |
115
+
|[-tp, --template-path[=TEMPLATE-PATH]](https://kitloong.github.io/laravel-migrations-generator/options/template-path/)| The location of the template for this generator |
116
+
|[--date[=DATE]](https://kitloong.github.io/laravel-migrations-generator/options/date/)| Migrations will be created with specified date. Views and foreign keys will be created with + 1 second. Date should be in format supported by `Carbon::parse`|
|[--log-with-batch[=LOG-WITH-BATCH]](https://kitloong.github.io/laravel-migrations-generator/options/log-with-batch/)| Log migrations with given batch number. We recommend using batch number 0 so that it becomes the first migration |
122
+
|[--default-index-names](https://kitloong.github.io/laravel-migrations-generator/options/default-index-names/)| Don\'t use DB index names for migrations |
123
+
|[--default-fk-names](https://kitloong.github.io/laravel-migrations-generator/options/default-fk-names/)| Don\'t use DB foreign key names for migrations |
124
+
|[--use-db-collation](https://kitloong.github.io/laravel-migrations-generator/options/use-db-collation/)| Generate migrations with existing DB collation |
125
+
|[--skip-log](https://kitloong.github.io/laravel-migrations-generator/options/skip-log/)| Don\'t log into migrations table |
|[--squash](https://kitloong.github.io/laravel-migrations-generator/options/squash/)| Generate all migrations into a single file |
130
+
|[--with-has-table](https://kitloong.github.io/laravel-migrations-generator/options/with-has-table/)| Check for the existence of a table using `hasTable`|
The `--connection` option allows you to specify the database connection to use. If you don't specify a connection, the default connection as defined in your Laravel's `config/database.php` will be used.
8
+
9
+
This option is particularly useful when you have multiple database connections defined in your Laravel application and you want to generate migrations for a specific connection.
10
+
11
+
### Example
12
+
13
+
Suppose you have a connection named `secondary` defined in your `config/database.php`. You can generate migrations for this connection by running:
The `--date` option allows you to specify the date for the generated migration files.
8
+
9
+
Migrations will be created with the specified date. Views, procedures, and foreign keys will be created with an additional 1 second.
10
+
11
+
The date should be in a format supported by [`Carbon::parse`](https://github.com/briannesbitt/Carbon/blob/d481d8d69a94dc00e5c1b147ec1f7e7492626b12/src/Carbon/Traits/Creator.php#L207).
The `--ignore` option allows you to specify which tables you want to exclude when generating migrations. This is useful when you want to generate migrations for all tables in your database except for a few specific ones.
8
+
9
+
### Example
10
+
11
+
To use the `--ignore` option, you need to provide a comma-separated list of table names. For example:
0 commit comments