Closed pezholio closed 6 years ago
Hey @pezholio,
The migrations of this gem are completely decoupled from ActiveRecord
itself, the examples show how to use them with ActiveRecord
because it's the most common use-case.
You can use them just like:
require 'contentful_model'
class AddNameToAuthor
include ContentfulModel::Migration::Migrations
def up
add_content_type_field 'author', 'name', :symbol
end
end
AddNameToAuthor.new.up
Then just execute this file to run the migration. Using ActiveRecord::Migration
as an engine is just a convenience for having the recorded history of ran migrations and to be able to run all of them at once when using rake db:migrate
. But as I said before, there is no coupling at all, so you can write your own migration scripts.
Hope this helps,
Cheers
Cool, that's awesome. I'll have a look and see how I get on 👍 There may be some reusable logic around rake tasks etc that I can contribute back.
I have a project that isn't backed by a database, so can't use the migrations module as set out in the examples. Is this something I'll have to build from scratch, or is there an existing solution kicking around that I may not have seen?
I've found the (not supported by Contentful) contentful-migrations.rb gem, but this has a dependency on the older version of the contentful-management gem, so I can't really use it.