Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: migrations #9

Open
caspiano opened this issue Jul 6, 2020 · 1 comment
Open

Feature: migrations #9

caspiano opened this issue Jul 6, 2020 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@caspiano
Copy link
Contributor

caspiano commented Jul 6, 2020

class Model < RethinkORM::Base
  include RethinkORM::Migration

  attribute name : String
  attribute age : Int32


  migration("0.1", "1") do |data, model|
      model.age = data["current_age"].as_i
      model
  end
end

the RethinkORM::Migration module exposes a macro migration(from : String, to : String, & : (JSON::Any, {{type}}) -> {{type}})

The version is extracted from the current package's version, and necessary migrations are run sequentially up to the current version.

@caspiano caspiano added the enhancement New feature or request label Jul 6, 2020
@stakach
Copy link
Member

stakach commented Jul 6, 2020

going to dump a bunch of migrations in here:

Renaming a column, reference: http://redlua.com/post/rename-a-field-in-rethinkdb/

r.db('place_development').table('metadata').replace(function(meta) {
  return meta.without('zone_id').merge({'parent_id': meta('zone_id')});
});

@caspiano caspiano self-assigned this Jul 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants