Class: ActiveVersion::Migrators::Base
- Inherits:
-
Object
- Object
- ActiveVersion::Migrators::Base
- Defined in:
- lib/active_version/migrators/base.rb
Overview
Base migrator for converting from other versioning libraries
Direct Known Subclasses
Constant Summary collapse
- AUDIT_STORAGES =
%i[json_column yaml_column mirror_columns].freeze
Class Method Summary collapse
-
.create_audit_table(table_name, options = {}) ⇒ Object
Migration helper for creating audit tables.
-
.create_revision_table(table_name, options = {}) ⇒ Object
Migration helper for creating revision tables.
-
.create_translation_table(table_name, options = {}) ⇒ Object
Migration helper for creating translation tables.
-
.migrate(model_class, options = {}) ⇒ Integer
Migrate data from another library.
Class Method Details
.create_audit_table(table_name, options = {}) ⇒ Object
Migration helper for creating audit tables
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/active_version/migrators/base.rb', line 17 def create_audit_table(table_name, = {}) = .dup storage = normalize_audit_storage(.delete(:storage)) mirror_columns = normalize_mirror_columns(.delete(:mirror_columns)) changes_column = (.delete(:changes_column) || :audited_changes).to_sym context_column = (.delete(:context_column) || :audited_context).to_sym create_table_with_plan( table_name, , audit_table_plan( table_name: table_name, storage: storage, mirror_columns: mirror_columns, changes_column: changes_column, context_column: context_column ) ) end |
.create_revision_table(table_name, options = {}) ⇒ Object
Migration helper for creating revision tables
38 39 40 |
# File 'lib/active_version/migrators/base.rb', line 38 def create_revision_table(table_name, = {}) create_table_with_plan(table_name, .dup, revision_table_plan(table_name)) end |
.create_translation_table(table_name, options = {}) ⇒ Object
Migration helper for creating translation tables
43 44 45 |
# File 'lib/active_version/migrators/base.rb', line 43 def create_translation_table(table_name, = {}) create_table_with_plan(table_name, .dup, translation_table_plan(table_name)) end |
.migrate(model_class, options = {}) ⇒ Integer
Migrate data from another library
12 13 14 |
# File 'lib/active_version/migrators/base.rb', line 12 def migrate(model_class, = {}) raise NotImplementedError, "Subclasses must implement migrate" end |