53

I know your method works flawlessly, but it scares the crap out of me. Luckily Craft's update setup is magical. What I do is this. Make sure my repo is clear of unstaged files, just so the update can be in a commit all by itself. Run the update on my local dev environment (with a local database) (Test) Commit the updated files and push Backup live ...


49

My general approach for this, not just with Craft, but with all CMSes is to have a shared database for development. It's not the most ideal solution, since there can be overwriting of work, but it at least prevents schema changes from having to be redone across multiple environments. Once a site goes live, maintaining a dev environment alongside live ...


17

Hmm. I started out having a feeling existing tools might be a best approach here. I soon found that even with the better of these, except for in-dev patching, we may want to wait for a Craft capability for transferring any less than a full dump of data in a Craft database. Syncing databases is a tricky problem, unless they are of exactly the same structural ...


15

I actually keep all the craft system files gitignored. This way, all the assets are independent of the version of Craft and therefore of the updates. When it's time to run an update, I'll do it on dev first and then I'll run it in production knowing that it'll be fine. So far I have not had a problem with this approach and it seems to me that it is a more ...


14

Yup! Just turn on devMode in your general config: return array( 'devMode' => true, ); And then just open up a console (Firebug, Chrome, etc) and look in the profiling summary report.


13

It is indeed possible. Craft has a handy general configuration option for this exact situation. return array( 'backupDbOnUpdate' => false ); Just add that to config/general.php and that should do the trick!


12

Make sure to change the "Site URL" setting to {siteUrl} in your control panel settings... Control Panel > Settings > General > "Site URL" Within your config file, you'll also want to put your siteUrl value inside of an Environment-Specific Variables sub-array: 'mynewcraftsite.dev' => array( 'devMode' => true, 'environmentVariables' => ...


11

Note: This method is not for the faint of heart and might not be for everybody, but can be useful in some situations. One thing we do (at Airtype Studio, where I work) for larger installations is set up a couple of load-balanced pools of servers: an app tier and a web tier. In fact, the environment architecture is very similar to this: This type of ...


11

I personally use a slightly different method than what Jeremy recommends. Clean repo on the git side of things: no unstaged or non committed files Backup live DB and import in dev Update dev (test) Update production Commit & deploy Not encountered any problem so far and Craft runs its tests on both environments.


10

Move the check the SERVER_NAME switch up above the require_once $path;. You need to set CRAFT_ENVIRONMENT earlier.


10

Make sure both Craft installs are up-to-date. Craft's license is saved in craft/config/license.key, make a backup of your purchased license file. Move all your files/directories except: /craft/app/ /craft/storage/ Copy the backup of your license.key to craft/config/. Remove /craft/storage/, if it exists on your new server, to prevent cache errors. "...


10

The difference in both size and speed is likely because Sequel Pro (and any other MySQL client) is likely using mysqldump, which is a native CLI command and highly optimized. Craft can't rely on that for a variety of reasons (PHP might have have exec permissions, the account Craft uses to connect to the database might not have the permissions necessary to ...


10

Craft imposes a default limit of 100 for element queries. To disable this you need to specify a limit of null. $criteria->limit = null;


9

I work with git for all my projects, I had to spend some time figuring out how to set up the folders and files, i.e.: what to gitignore. But it now works pretty well. All the core files are independent from the configuration/assets so it's pretty easy to work with once it's been setup. Now, in regards to the database, I have been working with separate, ...


9

TL/DR: MySQL is horrible. The craft_searchindex table is the only table that uses MySQL's older MyISAM storage engine, instead of InnoDB (like the rest of the tables), because InnoDB didn't add support for MySQL's full text search capabilities until very recently (version 5.6.4). One of the many drawbacks of the MyISAM storage engine, as you've discovered, ...


9

You can use either an activeRecord for it $customer = Customer::find() ->where(['id' => 123]) ->one(); Or a query $rows = (new \craft\db\Query()) ->select(['id', 'email']) ->from('user') ->where(['last_name' => 'Smith']) ->limit(10) ->all();


8

We currently handle this with database dumps from dev and taking screenshots of config screens and attaching them to git pull requests. There needs to be a better way though. The only CMS that has any kind of solution that I know of to this problem is Wordpress with this plugin https://deliciousbrains.com/wp-migrate-db-pro/


8

I found a great blog post where the author uses Phinx and MySQL Query Log to create database migrations. I summarized its content into 10 easy steps: Step 1 Enable the MySQL Query Log on your dev environment by editing your mysql my.cnf file. Set the general_log key to 1 and general_log_file to /var/log/mysql/mysql.log Step 2 Take a snapshot of your ...


8

Update: Craft 3 officially supports MariaDB 5.5+ now. https://docs.craftcms.com/v3/requirements.html Not officially, no. MariaDB is supposed to a "drop-in" replacement for MySQL, but there are clearly areas where it is not 1:1 compatible with MySQL: https://mariadb.com/kb/en/mariadb/mariadb-vs-mysql-compatibility/ We've seen some installations using ...


8

Have you tried it? I'm pretty sure that's not going to work as Active Record is tied to the db connection in craft/config/db.php hanging off of craft()->db. You should be able to pull it off with a plugin that instantiates its own DbConnection, though and uses Query Builder instead of Active Record. Completely untested, but something like this: $...


7

You are correct in stating that Records typically define a new custom table for your plugin. However, don't forget that Craft already comes with many pre-existing Records. Take a look inside this folder: /craft/app/records Although based on your question (and the ensuing comments thread), it looks like you may not need to tap directly into any Records at ...


7

If you delete the section, that will delete all the entries in the section as well.


7

If you want to delete users (or any other elements in Craft) directly from the database, the place to do that is the elements table. Delete the row(s) from there, and all the elements’ rows in the other tables will go away automatically.


7

Craft will run out-of-the-box with 32M of memory, no problem. However, memory consumption will start to increase depending on several factors including: The complexity of your site, including the number of fields, sections (and types of sections), categories, tags, users, entries, plugins in use (and how efficient they are working), etc. More importantly, ...


7

This feature has now made it into Craft core as of version 2.6. See this link for documentation on the subject: https://craftcms.com/docs/templating/eager-loading-elements


7

Completely untested but it looks like you're just querying a row instead of all. Update queryRow() to queryAll()


7

You can use Yii's migrate console command. Triggered in Craft 3 via craft migrate --type=app.


7

Craft 3 did away with the PHP-based database backup solution that Craft 2 utilized (for many reasons). Now it requires that the mysqldump executable (if you're using MySQL) or pg_dump executable (if you're using PostgreSQL) is available to PHP in order to do backups. This is usually just a matter of including the path to that executing in your PATH ...


6

You can get the fields that aren’t in use anywhere by running this SQL query: SELECT f.* FROM craft_fields f LEFT JOIN craft_fieldlayoutfields l ON l.fieldId = f.id WHERE l.id IS NULL The easiest way to delete them would be from the Control Panel, but if you really want to limit your work to the database, you would need to delete those fields’ rows in ...


6

I've been thinking about ways to achieve this recently, and I've put together a basic proof-of-concept plugin for fetching one level of relations for a collection of elements, with no more than two extra queries for each element type. One query to get the IDs of the related elements, and then another to actually fetch and return the elements with the ...


Only top voted, non community-wiki answers of a minimum length are eligible