I'm working for a company which is using PHP. There are different CMS Systems being used like Wordpress or Magento.
We are working with git having our own repository server and we have to deploy to different servers our different customers.
I've set up a deploymentscript using capistrano which works fine but the Database Synchronisation is quite tricky.
Imagine the live-database contains user data and I have to create some new features after the site already launched and there are loads of sql data within the database already. I personally work with a dummy database since I don't need any customer information.
How are you PHP geeks are deploying your databases? I don't want to change the contents but only migrate new or modified tables. I'm looking for a complete deployment solution for that. I'm also open for other options besides capistrano if needed. Especially with Magento I had serious problems to keep my database sync..
Any help is appreciated.
Recently I have discovered this project: http://dbv.vizuina.com/, but I don't have used it, otherwise Symfony has a similar feature called migrations and it works very well.
Related
I created a separate integration directory/project (let's call it as project-Interface) in Laravel and I created new DB (let's call it as DB-A) and 3 new tables (table-a,table-b,table-c) through artisan migrate command and models related to that as well in the solution.
Now there is a different project (let's call it as project-Web) in Laravel and it has its own database (let's call it as DB-B) and has its own tables and models created (table-x,table-y,table-z).
I need to do the following:
Can I use DB-B of table-x from project-Interface to save some
details in it?
Can I create the tables table-a,table-b and table-c from project-Interface through migrate command in DB-B?
Can I add some more columns in table-x from project-Interface and use it?
Can I use the existing DB connection of DB-B from the env file of project-Web and use it in env file of Project-Interface?
If yes, will it create a new table in DB-B of project-Web, if I created it from project-Interface? Will the changes reflect there also? Also, if I created new columns in table-x from project-Interface, will that column be reflected in project-Web?
So the purpose here is that the DB should be the same and it should be common wherein it should contain all the tables in it and whatever changes I am making from project-Interface or project-Web it should use the DB-B.
Some answers:
It seems that you are asking if you can write to database B in project A. The short answer is yes, if you can connect to it then you can write to it. The database does not know that you are connecting from a different Laravel project or a project sitting in a different repo - it only understands database users.
You can also run migrations belonging to another project, but based on the information so far, I would advise against this. I will explain more below.
Adding columns to a different database sounds like a restatement of question 2, and my answer would be the same.
The problem you have with mixing migrations is that the second project (project-Web) is not able to create all its tables. This will add complexity to:
creating a new development environment (e.g. when adding a new team member to the project)
creating automated database tests that need to tear down and recreate the database from scratch for every run
creating a new staging/production environment
Given that you want some communication between the two projects, I wonder if an HTTP API would be in order? This will be much easier to manage:
All your tables are stored in one project, and all your logic is stored here too. This will simplify migrations enormously (and thus the creation of all environments I mentioned earlier).
You can offer a web service in one project to offer read/write services to the other project. This is much easier to test from an automation standpoint: in the API project you can run API/HTTP tests, and in the client project, you can use mocks.
This approach will allow you to test the projects in isolation in a clean manner, and then do automated integration testing if you wish (e.g. by deploying both projects to a test server using CI/CD, running the migrations and any seed files, and then running tests on one that causes both projects to work together in the designed fashion).
I have just started with WordPress development and I ran into a pretty big roadblock. I used MAMP to develop the site locally, and chose WPEngine as my host.
I created a theme that utilized plugins like Custom Post Types UI, and Advanced Custom Forms. For this reason, I had to upload my local MySQL database to the host to keep all the data those plugins relied on.
This is all great and dandy, but there must be a better way than managing a local MySQL database, adding data to it, and then exporting it to later import it in the production database. Is there something I'm missing with this workflow?
EDIT: I also have to perform a find & replace on the URLs each time I migrate the DB's, thats a huge pain
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:
I'm updating an existing wordpress site making significant modifications the the theme and site structure, as well as making updates to plugins which in turn store their data into mysql database.
As far as I'm aware there are 2 (3?) possible strategies here:
'Dump-and-load' MySQL database from DEV to LIVE and replace wp-content folder with latest updates.
Import changes via WP-importer and replace wp-content folder with latest updates.
Make database changes manually via WP admin interface and replace wp-content folder with latest updates (this is useful only for minor changes).
While I am developing in my own separate environment this is for an existing website which is currently live and will continue to receive updates from the public such as comments and entries into contact forms, hence I expect the database to be different now from when I release my changes.
Given this the options above provide the following problems.
1. DUMP AND LOAD
The 'dump-and-load' strategy seems to be out of the question as my data is being updated behind the scenes (this would have been my preferred approach as this is easily rolled back).
Result: requires synchronising databases post release to get latest updates, TOO COMPLICATED.
2. USE THE IMPORTER
Using the WP-Importer plugin page and post IDs will get updated, screwing up styling that relies on the post IDs to get activated. This in turn creates a CSS nightmare that I wish to avoid, having to go though the CSS after release to update the new page/post IDs with the ones the database created.
Result: Too finicky, not very professional approach leading to long and complex release process.
3. UPDATE DATABASE MANUALLY
This option is great for small changes but when for more complex releases the list of steps to follow on the PROD interface becomes long and hard to follow, making it easy to make mistakes.
Result: Too easy to screw up, only a last resort.
IS THERE A STANDARD WORDPRESS RELEASE STRATEGY FOR EXISTING WEBSITES?
So basically, my question is: What release process do other wordpress developers follow when UPDATING an existing website? Is there an option that I have not listed below that minimizes hassle and reduces time and complexity during release?
I've set up source control for the site using GIT and I am used to automating things via ANT or similar release script, this may be overkill for the current project but would be ideal to at least know of a simple way to update a wordpress site and minimize the chances of screwing it up.
Thanks!
I don't think this is particular to WordPress, it's a similar situation to any custom site. I personally favor replaying the SQL changes on production that were made on dev. The tricky part is that you have to know what SQL changes were made. For example a certain plugin may make some schema changes when you install it - you need to know what they were. You can do that by creating an export of your DB as SQL before installing a plugin, then take another export after and do a diff on the files.
Since you say you're making the modifications then I might assume you know what SQL changes you are going to make? Just make sure all changes you make to the DB are in the form of SQL script files and not just editing using the GUI (you can use the GUI to help write the queries, but save the actual SQL). After all of your changes are done you should have a bunch of SQL scripts that you ran during your development process - you can re-run them in order without encountering errors.
Then when it's time to push to production, create a staging version of production (that is take a fairly current DB backup of production). Run your update scripts on that and test that everything is ok. If it is, then you can run on production.
definitely make a backup of production before running any changes on it!
The guy behind WordFence was working on a deployment plugin called
Deploymint.
There's a new one called WP Stack.
Metal Toad Media discussed using Capistrano, but that Capistrano isn't specific to WP.
CrowdFavorite launched a service called
RAMP.
Needless to say, you have some other options. If you're making db changes manually make sure you're working with the serialized data effectively. I recommend using Search and Replace DB. WordPress also had a great little trick for changing the site url entirely from the wp-config file.
I assume you have everything running in a test environment. I would then:
Create a new database in your live environment.
Preload it with all content and configurations for the new site.
In your test environment, configure your config.php to point to the new database.
Upload all files to the live server. Upload your config.php last.
This will minimize downtime.
I am about to use WordPress as CMS with a lot of customization, but my question is, how should I sync development to production?
Assuming WordPress is not used, a typical development cycle is to develop the pages locally, and create the DB scripts. Then when everything is ready, it is posted to the site. And then again, more db and code changes, then only the changes are updated/applied, and so on.
Now, with WordPress, you get all the great features (one example is blogging, comments, almost ready CMS ...etc). However deployment is a pain! Ideally, I would rather keep my typical development cycle described above. Therefore I am going to be implementing WordPress locally (from wordpress.org) and then pushing the changes to my production server.
So, assuming that I create a new page in WordPress locally (I will never create pages on the server, all locally, I will find a way to disable wp-admin for the server), a number of files are created. This is not a problem so far. HOWEVER, if I want to add content to that newly created page, that content is saved to my local database. Even though that content is a database change, it is considered (from my point of view) a new change that should be pushed to server rather than add that content via the live server (because that content is considered static, it is not a blog post or a comment, it is a static page).
Now, that new page content is saved to the DB, and therefore, the DB will have changes done on my local machine that I should push to the server along with the files that I will FTP to the server.
My questions are:
Is this approach correct? If not, what do you suggest
What is the best way to find database diffs? What is a tool to use? Does MySQL Workbench provide something like that? I intend to use that tool to find diffs and then generate an update script for the DB. The reason for this question is I normally make the changes myself, and I know how to track them, but now, those DB changes are generated by WordPress and I need to reverse engineer them to find out which changes are made.
Assuming I got step 2 to work, is there anything in that script that should be modified? Such as server names? Does WordPress hard-code server names for example?
So to summarize and give you more information about my development environment, I use XAMPP for development on Windows 7, with PHP and MySQL setup. I also use Mercurial for source control. As mentioned above, I will use WordPress as part of the solution and I intend to use it to help me create a CMS solution. I will use it locally for page generation, and disable that feature for online (keeping online for blog posts and similar entries only). I am doing that so as to keep things in-sync. If I create a page locally, some data is saved to the DB. Now, how do I sync/upload?
Thanks.
OK, after further investigation, here is what I concluded.
All theme development should be version-controlled
All plugin development should be version-controlled
Content of pages and posts are not part of the development porcess, this is contect and should only be backed up.
This way, you do not need to worry about DB changes ...etc.
Hope this helps everyone.
You might use a Version Control System? What OS is the development on, e.g. Win or Linux? And what is the production OS? I use http://serverpress.com for my testing environment though there are others, WAMP, LAMP, etc.