xethron / migrations-generator Goto Github PK
View Code? Open in Web Editor NEWLaravel Migrations Generator: Automatically generate your migrations from an existing database schema.
License: MIT License
Laravel Migrations Generator: Automatically generate your migrations from an existing database schema.
License: MIT License
Hi,
I want to use the migrations-generator. Trying the "php artisan" command I get the above error.
Here are my directories, the serviceproviders and the error:
https://gyazo.com/df1642a3b2dbc8c51337de4d71917d89
I'm using Laravel 5, PHP 5.6
Could you please help?
DB prefix is set in the settings, but exported migrations keep the prefix text on the table names, causing the table name to be incorrect when you later import it (creates prefix_prefix_tablename
)
Error when using composer update on laravel v5.1.17:
Problem 1
- The requested package way/generator could not be found in any version, there may be a typo in the package name.
Problem 2
- Installation request for xethron/migrations-generator dev-l5 -> satisfiable by xethron/migrations-generator[dev-l5].
- xethron/migrations-generator dev-l5 requires way/generators dev-feature/laravel-five-stable -> no matching package found.
Can you bump the version up to support Laravel 5 too.
I'm getting this error. I should have no typos. Everything is copied directly from the readme.
[RuntimeException]
Failed to clone [email protected]:jamisonvalenta/Laravel-4-generators.git, git was not found, check that it is installed and in your PATH env.
'git' is not recognized as an internal or external command,
operable program or batch file.
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.",
"phpunit/phpunit": "~4.0",
"symfony/css-selector": "2.8.|3.0.",
"symfony/dom-crawler": "2.8.|3.0.*",
"xethron/migrations-generator": "dev-l5",
"way/generators": "dev-feature/laravel-five-stable" },
"repositories": {
"repo-name": {
"type": "git",
"url": "[email protected]:jamisonvalenta/Laravel-4-generators.git"
}
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.",
"phpunit/phpunit": "~4.0",
"symfony/css-selector": "2.8.|3.0.",
"symfony/dom-crawler": "2.8.|3.0.*",
"xethron/migrations-generator": "dev-15",
"way/generators": "dev-feature/laravel-five-stable"
},
"repositories": {
"repo-name": {
"type": "git",
"url": "[email protected]:jamisonvalenta/Laravel-4-generators.git"
}
}
in my composer.json, I receive the error
"Xethron/migrations-generator could not be found or there is a typo"
I have followed the instructions to the letter on the library home page.
Hi,
I've just tested your generator and its working pretty well. I just noticed that double columns are converted to float(10,0). Is this behaviour intended?
Greets
I added some custom tables to my octobercms database and would like to generate a model from these tables, using this generator + https://packagist.org/packages/user11001/eloquent-model-generator
Now if I fire "php artisan migrate:generate" or even "php artisan help", the following error will appear:
[ErrorException]
Argument 5 passed to Xethron\MigrationsGenerator\MigrateGenerateCommand::__construct() must be an instance of Illuminate\Config\Repository, i
nstance of October\Rain\Config\Repository given, called in vendor/xethron/migrations-generator/src/Xethron/MigrationsGe
nerator/MigrationsGeneratorServiceProvider.php on line 30 and defined
Any idea how to fix this? Is it possible to use this within a OctoberCMS installation or have a setup another laravel environment for this migration first, and then put it manually it octobercms?
thx for help.
The export process grabs the tables exactly as they are in the db. So, if you have a prefix set, when you run the migration again you'll have prefix__prefix__tablename
which breaks all kinds of stuff.
Since the prefix is set on the database configuration, it should be removed from the table names when exporting.
Lets say I'm constructing db structure from EER diagram. Creating, updating, etc. Suppose I generated initial set of migrations. What happens if I change db structure as usually from EER diagram. Will it be able to detect the fact and create migration for changes only?
I have some booleans, not nullable, with default value: false.
The generated migration change the default to "blank": ->default('');
Greets
Is the installation procedure for the generator the same as Laravel 5? Or do the tools need to be updated to this version. I get a "Class 'Way\Generators\GeneratorServiceProvider' not found" exception when trying to run artisan.
hi
i think it is good to also create seed file from the existing data in tables
I'm running into this error:
[Doctrine\DBAL\DBALException]
Unknown database type enum requested, Doctrine\DBAL\Platforms\MySqlPlatform
may not support it.
My tables have enum() types.
Hi,
when $this->schema->listTableNames(); is called some table names are enclosed by double quotes.
For example table names like "order" or "user"
I know this could be more an issue of doctrine than yours, however i modified the getTables function...
public function getTables()
{
$tables = $this->schema->listTableNames();
if (is_array($tables))
{
for ($i = 0; $i < count($tables); $i++)
{
if (preg_match('/"/', $tables[$i]))
{
$tables[$i] = str_replace('"', '', $tables[$i]);
}
}
}
return $tables;
}
I am looking to use this package in the application as such: Artisan::call('migrate:generate');
. The interactive questions however limit me from doing so.
I'd like to propose integrating support for the --no-interaction
option and falling back to the default values for this.
Ran composer update with "xethron/migrations-generator": "dev-master"
in composer.json and got this error:
{"error":{"type":"Symfony\Component\Debug\Exception\FatalErrorException","message":"Class 'IlluXethron\MigrationsGenerator\MigrationsGeneratorServiceProviderminate\Workbench\WorkbenchServiceProvider' not found","file":"C:\Users\norm\trivia\bootstrap\compiled.php","line":4219}}Script php artisan clear-compiled handling the post-update-cmd event returned with an error
Problem may be that the namespace statement is on the same line as the php header in MigrationsGeneratorServiceProvider.php. It may not have been caught on linux but Windows may be sensitive to this:
I have application using C# and SQL server , now i want to generate model from SQL Server exists database and re-create on MySQL, is this work for SQL Server?
Thanks
When generating the dropForeign, laravel asks for the index name. The package is using the field name.
Having this up():
Schema::table('A', function(Blueprint $table)
{
$table->foreign('B_id', 'A_B_id_fkey')->references('id')->on('B')->onUpdate('RESTRICT')->onDelete('RESTRICT');
});
Generates this down:
Schema::table('A', function(Blueprint $table)
{
$table->dropForeign('B_id');
});
Should generate:
Schema::table('A', function(Blueprint $table)
{
$table->dropForeign('A_B_id_fkey');
});
I'm not sure Way's new generator is simply not working with yours, or just that you didn't informed?
We have the following migration and when we run tests they fail because
PDOException: SQLSTATE[HY000]: General error: 1 there is already a table named block
Here's the migration:
public function up()
{
Schema::create('block', function(Blueprint $table)
{
$table->increments('block_id');
$table->string('field')->default('')->index('field');
$table->string('operator', 6)->default('')->index('operator');
$table->string('block')->default('')->index('block');
$table->integer('weight')->unsigned()->nullable()->default(1)->index('weight');
$table->string('added_by', 16)->nullable();
$table->timestamp('ts')->default(DB::raw('CURRENT_TIMESTAMP'));
});
}
I removed the index->()
calls and the error went away.
Let me know what other info i can provide that might be of help.
Postgres UUID columns are generated as $table->guid, resulting in
PHP Fatal error: Call to undefined method Illuminate\Database\Schema\Blueprint::guid()
The right method name is Blueprint::uuid(), so it's temporarily fixed by a replace.
Used versions: Laravel 5.2.10, PostgreSQL 9.3
I got "Undefined index: index_type" error. I followed these steps. I dont know why I got this error.
root@user-System-Product-Name:/var/www/x# php artisan migrate:generate
Using connection: mysql
Generating migrations for: x, y, z, Etc
Do you want to log these migrations in the migrations table? [Y/n] :
Y
Next Batch Number is: 1. We recommend using Batch Number 0 so that it becomes the "first" migration [Default: 0] :
0
Setting up Tables and Index Migrations
[ErrorException]
Undefined index: index_type
I'm using PostgreSQL and I have two tables with a JSON datatype. When generating migrations it throws the error "Unknown database type json requested, Doctrine\DBAL\Platforms\PostgresqlPlatform may not support it".
I fixed it by adding:
$connection->getDatabasePlatform()->registerDoctrineTypeMapping('json', 'string');
to \Xethron\MigrationsGenerator\Generators\SchemaGenerator in the constructor
When running composer update.
Problem 1
- Installation request for xethron/migrations-generator dev-master -> satisfiable by xethron/migrations-generator[dev-master].
- xethron/migrations-generator dev-master requires way/generators 2.* -> no matching package found.
I had "way/generators": "dev-master"
installed.
Thanks for the script.
Any ideas? Works without --ignore option.
{"error":{"type":"Symfony\Component\Debug\Exception\FatalErrorException","message":"Unsupported operand types","file":"...../vendor/xethron/migrations-generator/src/Xethron/MigrationsGenerator/MigrateGenerateCommand.php","line":145}}
I followed the instructions on the readme homepage: put the file in composer.json, ran composer update, and got the Way and Xethron PHP libraries put in my vendor dir, and added the two lines of services providers to the providers array in config/app.php. When I try and run "php artisan migrate:generate," I get the following error message:
C:\xampp\htdocs\workflow>php artisan migrate:generate
{"error":{"type":"Symfony\Component\Debug\Exception\FatalErrorException","me
ssage":"Class 'Way\Generators\GeneratorsServiceProvider' not found","file":"C:
\xampp\htdocs\workflow\vendor\laravel\framework\src\Illuminate\Foundati
on\ProviderRepository.php","line":123}}{"error":{"type":"Symfony\Component\De
bug\Exception\FatalErrorException","message":"Class 'Way\Generators\Generato
rsServiceProvider' not found","file":"C:\xampp\htdocs\workflow\vendor\larav
el\framework\src\Illuminate\Foundation\ProviderRepository.php","line":123}}
How do I fix this?
I have a table with boolean field with default value set as false. When I run migration it shows
$table->boolean('deleted')->default('');
default is shown as null field. Can you please check and let me know a solution for same
The requested package way/generators dev-feature/laravel-five-stable exists as way/generators[1.0, 1.1, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.6.1, 3, 3.0.1, 3.0.2, 3.0.3, dev-master, dev-rewrite] but these are rejected by your constraint.
Pulling in way/generators:dev-master does work but then the migrations-generator fails with
" - Installation request for xethron/migrations-generator dev-l5 -> satisfiable by xethron/migrations-generator[dev-l5].
- xethron/migrations-generator dev-l5 requires way/generators dev-feature/laravel-five-stable -> no matching package found"
The export should always skip the migrations table, since the migrate command will create one, then when it gets to the create_migrations_table
migration, it errors. (I've never written the word migration
that many times before)
Problem 1
- Installation request for xethron/migrations-generator dev-master -> satisfiable by xethron/migrations-generator[dev-master].
- xethron/migrations-generator dev-master requires way/generators 2.* -> no matching package found.
Potential causes:
Read http://getcomposer.org/doc/articles/troubleshooting.md for further common problems.
In my composer file:
"require-dev": {
"way/generators": "~3.0",
"xethron/migrations-generator": "dev-master"
}
Hi guys,
Sorry if I ask a stupid question, but is it possible in this migration generator that the stored procedure get migrated out as well?
Although this adds the "generate" functions to artisan, they do not work with Laravel 5, only migrate:generate
has been made to work with L5. Perhaps a note stating this in the readme would be useful.
Updated: It seems as though some of the generate functions do work as expected, resource
for example. scaffold
does not however.
Hi,
very useful package! :)
I found this issue: when generating migrations of tables with an unsigned increments('column'), the unsigned part is not taken.
To be some specific, if we take a table created with:
Schema::create('tb_users_assigned_roles', function($table)
{
$table->increments('id')->unsigned();
$table->integer('user_id')->unsigned();
$table->integer('role_id')->unsigned();
$table->foreign('user_id')->references('id')->on('tb_users');
$table->foreign('role_id')->references('id')->on('roles');
});
migrations-generator creates the following migration:
Schema::create('tb_users_assigned_roles', function(Blueprint $table)
{
$table->increments('id');
$table->integer('user_id')->unsigned()->index('`assigned_roles_user_id_foreign`');
$table->integer('role_id')->unsigned()->index('`assigned_roles_role_id_foreign`');
});
that is, the ->unsigned(); part of the first column is lost.
If I find other problems, I'll report them!
Hey, could you make an option so we could make it generate all inno db tables? You really just need to make it add the line $table->engine = "InnoDB"; to each create file, and I looked through it but I just couldn't find where I would make changes to make this possible.
Hi,
migrations for foreign keys are properly generated but those cascades like "onDelete" won't be added to the migrations.
config/database.php 'fetch' => PDO::FETCH_ASSOC on enum error on FieldGenerator.php line 76.
I have the following line in a generated migration:
$table->float('more_than', 10, 0)->default(25)->index('`more_than`');
Which is in turn generating the following error:
[Illuminate\Database\QueryException]
SQLSTATE[HY000]: General error: 1 index more_than already exists (SQL: create index `more_than` on "discounts" ("more_than"))
Moving the index step to its own line (and removing the backticks, ha ha) works fine:
$table->index('more_than');
But the following line works just fine (backticks and all):
$table->enum('shipmethod', array('1', '2', '3', '4', '5', '6', '7'))->default('1')->index('`shipmethod`');
When the app create the file add_foreign_key_to_TABLE creates as an example:
up() Method: $table->foreign('account', 'account_fi1kk')->references('number')->on('accounts');
down() Method: $table->dropForeign('account');
Down method isn't correct in laravel 4, must be $table->dropForeign('account_fi1kk'); if not is not possible to rollback because laravel returns an General error: 1025 Error on rename of table because can't remove foreign key
Supposing you have this:
mysql> create table test (`foo.bar` int);
Query OK, 0 rows affected (0.05 sec)
mysql> describe test;
+---------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+---------+------+-----+---------+-------+
| foo.bar | int(11) | YES | | NULL | |
+---------+---------+------+-----+---------+-------+
1 row in set (0.00 sec)
Then the generated migration $table->integer('foo.bar')->nullable();
is incorrect: Eloquent explodes that to a table name and column, that is this incorrect SQL:
create table test (`foo`.`bar` int); /* oops, no table `foo` */
The proper generation should be:
$table->integer(DB::raw('`foo.bar`')->nullable();
where both the list of reserved characters and the escape character is driver-specific. The patch for this seems straightforward: if the column name contains a driver-specific reserved character, wrap the generation in a DB::raw
using the driver-specific escape character. Possibly an even simpler solution is to wrap ALL column names in DB::raw
...
P.S.: I'm not saying a column like this is a good idea! I did just encounter it, though, reversing a legacy system.
The generated migrations have backticks in the index names, like this:
$table->integer('affiliate_id')->index('`affiliate_actions_affiliate_id`');
These cause errors in PostgreSQL, as the backtick character is not ANSI SQL, and is specific to MySQL only.
Error text in console from Artisan:
[Illuminate\Database\QueryException]
SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "`"
LINE 1: create index `admins_user_id` on "admins" ("user_id")
^ (SQL: create index `admins_user_id` on "admins" ("user_id"))
Index names without the backticks works fine, however:
$table->integer('affiliate_id')->index('affiliate_actions_affiliate_id');
composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for xethron/migrations-generator dev-l5 -> satisfiable by xethron/migrations-generator[dev-l5].
- xethron/migrations-generator dev-l5 requires way/generators dev-feature/laravel-five-stable -> no matching package found.
Potential causes:
Read http://getcomposer.org/doc/articles/troubleshooting.md for further common problems.
I am using L5.1 and it worked fine for me and I am thankful about that.
But ubable to fetch comments from tables so I added them manually.
The generate operation doesn't keep the columns unique, the unique option seems to be completely ignored. I have only indexed unique columns in the table I've experienced the issue with - the indexes are exported correctly, but the unique option is gone after generation.
before:
$table->string('xx');
$table->index('xx');
$table->unique('xx');`
after:
$table->string('xx')->index();
Hey, since way/generator has supported L5, do i still need to installed the forked one since I have already installed the original way/generator for laravel 5?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.