...latter is invoked, which performs the actual migrations. Knowing this, it is easy to dump the db only if migrations will run. First, enable conditional migrations: # config/deploy.rb set :conditionally_migrate...

...migrating runs them before 'deploy:migrating', 'db:dump' Background In case you haven't employed dump-creation on deploy before, you can do it like this: Install geordi on your...

It sometimes happen that a database dump, that would want to insert into your development database, does not match the current schema of the database. This often happens when you...

...have an old dump, but your current setup is up to date with the the master. Hint: In most cases it is sufficient to delete and recreate the local database...

...Get the stage1 and stage2 MySQL credentials: cat /opt/www/the_stage.host.tld/current/config/database.yml cat config/database.yml # should do it Dump the table to a path reachable by the stage2 user (e.g. home): mysqldump -h mysql1...

(-h stands for hostname and it is in deed 'mysql1') Import the dump: mysql -h mysql1 -u stage_2_user -p stage_2_database < /home/stage_1_user/table_name_dump.mysql # attention to stage1...

This script loads a dump into your development database. You can provide the full path to you database dump like this: load-dump path/to/my.dump When you call load-dump without...

...any arguments it will show a menu with all dumps in your ~/dumps/ folder. load-dump This script is part of our geordi gem on github...

makandra dev

...our application servers (and called when deploying) but it also works locally. Just call dumple development from your project directory to dump your database. This script is part of our...

I had a huge MySQL dump that took forever (as in: days) to import, while I actually just wanted to have the full database structure with some data to use...

...my development machine. After trying several suggestions on how to speed up slow MySQL dump imports (which did not result in any significant improvement), I chose to import just some...

Sometimes you want to test migrations with production or staging data. Dumping single tables makes sense if a complete dump would be to big. mysqldump -u deploy_user -p application...

...table1 table2 table2 > table1_table2_table2.sql.dump Hint: If a table has to many constraints, a complete dump could be more handy. Further reading: How to load only a subset of a massive...

If you want to load an SQL dump from an ActiveRecord migration, you might find this to be harder than you thought. While you can call ActiveRecord::Base.connection.execute(sql) to...

...multiple statements per call. Below is an example for a migration that loads a dump from db/production_structure.sql: class LoadDump < ActiveRecord::Migration def up config = YAML.load_file('config/database.yml')[RAILS_ENV].symbolize...

...to easily get dumps of our productions machines, too. This is how we do it: dump-for staging [-s] It will copy the dump to your project's tmp directory...

...you're calling for, here: staging.dump. When you pass the optional -s option, the dump will automatically been sourced into your local development database. This script is part of our...

...Ruby code to config/initializers, or paste it into your IRB console. You can now dump any two-dimensional array to an Excel .xls spreadsheet with a single method call:

end table.dump_to_excel('users.xls') The first row in the array will be dumped as the table head in bold type. You need the spreadsheet gem in your Gemfile...

deadlock 0x7f8a4160a360: sleep:- (main) - /home/me/.rbenv/versions/1.8.7-p375/lib/ruby/gems/1.8/gems/bundler-1.14.3/lib/bundler/worker.rb:43 deadlock 0x7f8a38c03b08: sleep:- - /home/me/.rbenv/versions/1.8.7-p375/lib/ruby/gems/1.8/gems/bundler-1.14.3/lib/bundler/worker.rb:56 *** longjmp causes uninitialized stack frame ***: /home/me/.rbenv/versions/1.8.7-p375/bin/ruby terminated

I recently encountered the error above when I was running selenium tests. Thanks to a post on stackoverflow I found...

When restoring a PostgreSQL dump using pg_restore, you usually add the --clean flag to remove any existing data from tables. Note that this only removes data from tables that...

...are part of the dump and will not remove any extra tables. You need to do that yourself. When is this relevant? As an example: You want to load a...

When loading a database dump created with pg_dump into your database, you might run into an error like pg_restore: error: unsupported version (1.15) in file header

...local pg_restore version is too old to match the format created by pg_dump. The version of the PostgreSQL server doesn't matter here. For example, the official Ubuntu...

...database table sizes Some table may grow more than you expected. If they do, dump size will increase (making backups and other dump operations more expensive) and your application might...

...instea of db/schema.rb. As structure.sql is created by a database-specific tool like pg_dump, you can now serialize every single schema property, including proprietary features. Unfortunately using structure.sql comes...

...version of the database server, but different versions of their CLI tools (e.g. pg_dump 16 vs. 17). Two developers use the same versions of everything, but one developer has...

makandra dev

...Improve detection of IRB version Add new hints to 'Did you know' Breaking changes dump command: Drop and recreate the database before restoring a postgres dump. This mitigates the problem...

...of database schemas differing between your current local database and the database of the dump. Differing database schemas could lead to errors when running migrations. drop_databases command: The connection...

...an object. A deserialized object cannot be saved to database directly as the the dumped object was not marked dirty, thus rails does not see the need to save it...

...is base64 encoded, otherwise you might run into issues with mismatching encodings of the dumped string and the file encoding. Below is a use case where I had to export...

...are using JSON. To safely write and read YAML files you should use Psych#dump (String#to_yaml) and Psych.safe_load (YAML.safe_load): data = {'key' => 'value'}.to_yaml => "---\nkey: value...

...place. All of them are a side effect that you can not configure Psych#dump to only write safe data. Pitfall 1: Psych::DisallowedClass Psych#safe_load only whitelists the...

...say that you have something like that in your config/deploy.rb to create a database dump every time you deploy: before 'deploy', 'db:dump' This will not be called for cap...

...just use the deploy hook for important things. So instead of... before 'deploy', 'db:dump' after 'deploy', 'craken:install' after 'deploy', 'db:show_dump_usage' ...you say... before 'deploy:update...

makandra dev

When you have a hook in your Capistrano file that dumps your remote database, you might not want it to dump each time you deploy (say, you're experimenting with...

...staging and don't want ten dumps an hour). How to skip dump creation: Capistrano 2 In your Capistrano file: before 'deploy:update_code', 'db:dump' unless fetch(:skip_dump...

...but others won't need them – e.g. some notes, a log, or a database dump. Sure, you have a project directory – but all of it is tracked by Git. A...

...character set from messing with imports, use -r to export and SOURCE when importing. Dumping safely # Do not do this, since it might screw up encoding mysqldump -uroot -p database...

...you need to do mysqldump --default-character-set=latin1 (!) to get a correctly encoded dump. In that case you will also need to remove the SET NAMES='latin1' comment at...

makandra dev

Option 1: JSON dump In config/webpack/environment.js you can get inspect environment which includes all webpack config options set for the current environment: const { environment } = require('@rails/webpacker') const webpack = require('webpack...