{"id":22946610,"url":"https://github.com/mmower/simply_versioned","last_synced_at":"2025-10-26T04:40:04.252Z","repository":{"id":66365703,"uuid":"139","full_name":"mmower/simply_versioned","owner":"mmower","description":"A simple, non-invasive, approach to versioning ActiveRecord models","archived":false,"fork":false,"pushed_at":"2008-03-26T19:09:50.000Z","size":661,"stargazers_count":45,"open_issues_count":0,"forks_count":50,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-01T12:50:46.354Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://softwareheretics.com/plugins/simply_versioned","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mmower.png","metadata":{"files":{"readme":"README","changelog":"CHANGES","contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2008-01-28T20:19:14.000Z","updated_at":"2024-12-02T07:49:34.000Z","dependencies_parsed_at":"2023-02-20T03:00:20.660Z","dependency_job_id":null,"html_url":"https://github.com/mmower/simply_versioned","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mmower/simply_versioned","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmower%2Fsimply_versioned","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmower%2Fsimply_versioned/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmower%2Fsimply_versioned/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmower%2Fsimply_versioned/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mmower","download_url":"https://codeload.github.com/mmower/simply_versioned/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmower%2Fsimply_versioned/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260299800,"owners_count":22988670,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-14T14:47:27.082Z","updated_at":"2025-10-26T04:40:04.138Z","avatar_url":"https://github.com/mmower.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"SimplyVersioned\n===============\n\nRelease:\t1.0.0\nDate:\t\t\t28-01-2008\nAuthor:\t\tMatt Mower \u003cself@mattmower.com\u003e\n\nSimplyVersioned is a simple, non-invasive, approach to versioning ActiveRecord models.\n\nSimplyVersioned does not require any structural change to the models to be versioned and requires only one versions table to be created (a migration generator is supplied with the plugin) for the application, regardless of the number of models being versioned.\n\nThe plugin introduces a 'Version' ActiveRecord model (that reflects changes to model attributes) to which versioned models are polymorphically associated. Version records store the model information as a YAML hash.\n\t\nSimplyVersioned meets a simple need for model versioning. If your needs are more complex maybe try Rick Olsen's acts_as_versioned (http://svn.techno-weenie.net/projects/plugins/acts_as_versioned/).\n\t\nSimplyVersioned is (so far) actively tested with Rails 2.0.2 and Ruby 1.8.6\n\t\nUsage\n=====\n\n1. Install the plugin\n\n  ./script/plugin install http://rubymatt.rubyforge.org/svn/simply_versioned\n\n2. Generate the migration\n\n  ./script/generate simply_versioned_migration\n\n\tNote that the migration defaults to storing the version info in a TEXT field. On MySQL this will default to a\n\tlimit of 64K. If you are versioning particularly large models you will want to modify the migration to include\n\ta :limit =\u003e n condition to promote the yaml column to a MEDIUMTEXT or (god forbid) a LONGTEXT.\n\n3. Create the versions table\n\n  rake db:migrate\n\n4. Annotate the models you want to version specifying how many versions to keep\n\n\tclass Thing \u003c ActiveRecord::Base\n\t  simply_versioned :keep =\u003e 10\n\tend\n\t\n\tIf you do not specify a limit then old versions are never automatically deleted. You can\n\tmanually delete them like this:\n\t\n\tthing.versions.purge( 10 )\n\t\n\twhich would delete all the but the last ten versions.\n\t\n\tIf you want fine-grained control over when versions are created you can use:\n\t\n\tclass Thing \u003c ActiveRecord::Base\n\t\tsimply_versioned :automatic =\u003e false\n\tend\n\t\n\tand new versions will no longer be created by default. You will then need to use\n\tthe with_versioning method to create a version.\n\t\n\tLastly you can control which columns will be versioned by specifying an exclude parameter.\n\t\n\tclass Thing \u003c ActiveRecord::Base\n\t\tsimply_versioned :exclude =\u003e :awkward_column\n\tend\n\t\t\n\tor\t\n\t\n\tclass Thing \u003c ActiveRecord::Base\n\t\tsimply_versioned :exclude =\u003e [:first_awkward_column,:second_awkward_column,...]\n\tend\n\t\n\tThis may be helpful if you run into conflicts with other plugins which try to manage columns.\n\n5. Create versions\n\n\tthing = Thing.create!( :foo =\u003e bar ) # creates v1\n\tthing.foo = baz\n\tthing.save! # creates v2\n\t\n\tIf you need to control whether a version is created or not, use #with_versioning. For example:\n\t\n\tthing.with_versioning( false ) do |t|\n\t\tt.save!\n\tend\n\t\n\tor, using the \"magic pen\" (http://dablog.rubypal.com/2007/2/18/the-magic-pens-of-ruby thanks hmj):\n\t\n\tthing.with_versioning( false, \u0026:save! )\n\n6. Find versions\n\n\tthing.versions.each do |version| ... end\n\trender :partial =\u003e 'thing_version', :collection =\u003e thing.versions\n\tthing.versions.current\n\tthing.versions.first\n\tthing.versions.get( 3 )\n\t\n\tTo find a version number:\n\t\n\tthing.version_number\n\n7. Revert to a previous version\n\n\tthing.revert_to_version( 5 )\n\t\n\tIf a specific reversion needs to avoid overwriting some column values pass\n\tan :except option, e.g.\n\t\n\tthing.revert_to_version( 1, :except =\u003e [:name,:age] )\n\t\n\tThe revert_to_version method also takes an existing Version instance, e.g.\n\t\n\tversion = thing.versions.find( ... )\n\tthing.revert_to_version( version )\n\n8. Traverse versions\n\n\tthing.versions.current.previous\n\tthing.versions.first.next\n\n9. Obtain a copy of a previous versioned model\n\n\tthing.versions.first.model # =\u003e Instantiated Thing with versioned values\n\t\nThanks to:\n\n\tChris Wanstrath (http://ozmm.org/) for useful feedback and GitHub\n\tJosh Susser (http://blog.hasmanythrough.com/) for useful suggestions and feedback\n\tRick Olson (http://techno-weenie.net/) for all the many plugins whose code i've read\n\t\nCopyright (c) 2007 Matt Mower \u003cself@mattmower.com\u003e and released under the MIT license\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmower%2Fsimply_versioned","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmmower%2Fsimply_versioned","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmower%2Fsimply_versioned/lists"}