...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...
If you have a PostgreSQL dump in the custom format you can can view the text format dump (plain SQL statements). PostgreSQL 12 and newer Write it as a textdump...
pg_restore $dumpname -f name.textdump Applying parameters You can apply the same parameters for the output of the textdump as for restoring the dump (for e.g. --clean...
...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...
This card is just about creating simple PostgreSQL dumps. This is no instruction for a backup strategy nor a guide for SQL dump performance optimization. Read before starting
...mind that you should stop the replication on a slave PostgreSQL server before creating dumps Dumps can get huge, be careful so that the system running a production PostgreSQL won...
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...
File import/export Caution Target data will also be overwriten! # Create dump ./riot file-export -h 127.0.0.1 -p 6379 dump.json Exporting 100% [====================================================] 2630/2630...
# Restore dump ./riot file-import -u "$REDIS_URL_TARGET" dump.json Importing dump.json ? % [ = ] 2630/? (0:00:02 / ?) 1315.0/s
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...
...and may even perform better. Exercises Cards query (makandra only) Ask someone for a dump of the staging target and load it into your local database. In the makandra cards...
...be highlighted visually. To get realistic data for this exercise, ask someone for a dump of the makandra stage and load it into your local database. Push your changes into...
There is an issue with when restoring a PostgreSQL dump created with pg_dump < v11 with pg_restore > v10: pg_restore: [archiver (db)] could not execute query: ERROR: schema "public...
Command was: CREATE SCHEMA public; Convert If you want to restore this dump you should convert the dump to the text format first and comment out the CREATE...
...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...
...This is an edge-case. You probably don't want to mix different database dumps. It also requires that the mixed tables do not share relations to other database objects...
You've got two database dumps: dump_a.pgdump dump_b.pgdump Both dumps include these tables: foobar barfoo foobaz You want to create a dump with: dump_a.foobar dump_b.barfoo dump_a.foobaz Invalid and incomplete...
...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...