What php frameworks have database migration support? - php

I'm looking for a good php framework with support for handling database migrations. Ideally I would like to be able to run a command that generates a migration script, one that updates the database with changes and can handle rolling back those changes. Is there anything out there that does this?

The Doctrine project supports migrations - http://www.doctrine-project.org/projects/migrations/2.0/docs/reference/introduction/en
Hmm, that documentation is a bit lacking, at least in the introduction. Hopefully it gets better as it goes on.
Whilst most popular in Symfony, this can easily be integrated into other frameworks or even used on its own.

Promising, but not yet have a stable version : https://github.com/fuel/fuel

There is a new php framework called Laravel and it has migrations the same way as ruby on rails. It seems so pretty!
You can find it at http://laravel.com/
Migrations Docs
In addition, the framework introduces the idea of bundles, what can give to your project a great modular view.
If you try it, tell us your experience! :)

symfony - http://www.symfony-project.org/
In symfony you can write database schema using ORM like Propel, it is independant from database driver. If you have a database already, you want to migrate to a different db, I think you can dump the db, change the db config, and re-import it to the new db. (though I have not tried it myself.)

There are much php framework over there that can use any database. For example Zend, Ci, Cake and many others. One thing you should do is change database type that's usually stored in configuration file. And then migrate your database manually. No framework that can generate migration script automatically. U can also use ESF for database migration

Related

Db migrations in zend framework 2

I was using Yii2 framework for a long time. There is a DB migrations in Yii2 (http://www.yiiframework.com/doc-2.0/guide-db-migrations.html). It helps easily change DB structure by console command.
Is there something similar to Yii2 DB migrations in Zend Framework 2?
In Zend Framework 2 there are some possibilities to manage database migrations. First it depends what you are using to interact with the database. If you are using Doctrine you could use https://github.com/MurgaNikolay/DoctrineMigrationsModule.
If you are using Zend\Db instead, you could use this module: https://github.com/vadim-knyzev/ZendDbMigrations (documentation is in russian...).
There are some general modules that help you managing migrations: https://github.com/vgarvardt/ZfSimpleMigrations (the one with the most activity in the repo) or https://github.com/valorin/zf2-phinx-module that is using Phinx under the hood.
If you want to have a look to something really new, go to https://github.com/baleen/migrations, a really nice project that is being developed. This will probably require some work on your end to put the pieces together.

Laravel Existing Database

I have a database we use on some of our existing websites, sites were built in Yii framework by another developer so no Laravel, I have set up a new project using laravel but am looking for the best way to link up to that database and return the information.
linking to the database is easy enough, just change the database.php file but I am getting really confused with migrations part and how to call it into a webpage.
So what's the simplest way to go about doing this?
Migrations are used to create or modify database structure. Since you already have a database set up, you don't need to use migrations.
To get accustomed with Laravel I strongly suggest watching:
Laracasts - Laravel 5 Fundamentals
I also suggest you go over the entire Laravel Documentation just to get acquainted with all the framework has to offer.

PHP MySQL migration tool

I have a migration tool that I'm supposed to use, but the old programmer never left any documentation on how to use it and we are unable to contact him.
This is the tool here:
https://github.com/davesloan/mysql-php-migrations
I have a MySQL database set up with Joomla for both locally and on the server. What I need to do is migrate the new MySQL local files to the server(We are using github for pushing and pulling.)
Anyone know how I can do so with this tool? I fiddled with the command line a bit but never got any results.
Thank you.
I'd recommend using a different tool, where you have documentation, otherwise it's going to be tough deconstructing this.
I built a migrations tool that would work perfectly for what you need:
http://andrefigueira.github.io/Schematic/
It will map existing databases into the configuration files (schema files) and then can be used for future modifications, and these schema files are designed to be committed to your VCS and It's very simple to use.
You may try LazyRecord https://github.com/c9s/LazyRecord
LazyRecord integrates full featured PHP-based schema and the related migration features.
The most powerful feature is - automatic migration, which is similar to UIKit's lightweight database migration.
here are some screencasts:

Is there any PHP framework's scaffolding that can generate migration like Ruby on Rails?

In rails, when generating model, migration is created also.
I'm wondering any PHP framework can do it also?
I'm trying Yii framework now, but seems like I need to generate the migration manually first then generate a model. (or even a third step to generate CRUD :-/)
Thanks
CakePHP has a migrations plugin, as well as bake console which creates a file to generate your current schema and stuff. I think this might be what you need..
I believe the old Yii dbmigrations extension is obsolete in favor of Yii's built-in migration functions available since Yii 1.1.6: http://www.yiiframework.com/doc/guide/1.1/en/database.migration
However, it does seem like the OP may have tried that already as was not happy with the amount of manual work still involved compared to his experience with RoR.
I suggest you try fuelphp framework (http://fuelphp.com) which has excellent scaffold function as well as other amazing functions. It used PHP 5.3.
Doctrine 2 has a migrations component. It's completely separate from the ORM, so you don't have to be using Doctrine to use this. This is probably the most popular solution right now.
It does require php 5.3 though.

Data import and migrate using Doctrine

I need to load data from an old DB into a migrated schema of this DB using Doctrine migration system.
I guess Doctrine might help me in this process.
I tried and lost a few hours using ETL scripts programs, without success.
From my point of view I need to :
Create a DB with the V0 schema
Load the data from the old DB (schema are identical)
Migrate DB to latest version using Doctrine migration
Extract data
Load it in the new DB
WHat do you think of this process?
Do you think it is feasable using Doctrine?
I tried a few searches on Google without success.
I am currently reviewed the features of Doctrine_Core class.
Thanks for your help
Yes, it is possible to migrate data from one database to another using Doctrine.
It sounds like you're trying to do a one-time database revision and migration and that your applications are not currently written using Doctrine. In that scenario, database abstraction has little or no benefit, unless you're also rewriting the applications to use it.
If you have no prior experience using Doctrine then I seriously doubt that writing custom migration classes in it will be easier than doing it with whatever database API you are already experienced using. It makes sense to use the migration classes (some times) if you are already using Doctrine for your development. Otherwise it's another layer and API you don't need.
I'm using Doctrine 1.2, which has some nice features for migrations but also a number of bugs and omissions of expected functionality. Reportedly version 2 improves on this but I haven't used it yet.

Categories