ActiveRecordSqlExporter
=======================
This plugin takes a record in your database and converts it into SQL statements
that can be used to insert it.
This was written after I had to restore some specific data for a user (a number
of rows, across a number of tables.)
It might be useful as a simple backup utility - for example, store the restoration
sql after something gets removed.
This moves down through relations along has_many, has_one relations, but will
not move up along belongs_to relations.
However, this doesn't make you any less likely to screw up and shoot yourself
in the proverbial memory usage foot with a massive swath of data, so often
you'll want to use the second argument to to_sql, which is an array of classes
to ignore.
Example
=======
Obj.find( obj_id ).to_backup_sql
For a blog_post, that belongs to a user, that might have many posts:
Post.find( id ).to_backup_sql( {}, [User] )
Export an object to a file:
Post.find( id ).to_backup_sql( {:file => a_file_object} )
Copyright (c) 2010 Adam Palmblad (adam.palmblad@teampages.com), released under the MIT license
To Do
=====
* Watch dependent => nullify and write restoration query
* The generation the SQL that checks for the presence of a value is broken!
* Add ability to toggle sql options, such as the ON DUPLICATE KEY stuff
* Support for non MySQL databases
Project
active_record_sql_exporter
Quickly export an active record object to raw sql, useful for restoring partial data from a backup
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
Development
Dependencies
Runtime
< 5
Project Readme