Class: ElasticsearchRecord::SchemaMigration
- Defined in:
- lib/elasticsearch_record/schema_migration.rb
Overview
:nodoc:
Class Method Summary collapse
- .all_versions ⇒ Object
- .create_table ⇒ Object
- .drop_table ⇒ Object
- .normalize_migration_number(number) ⇒ Object
- .normalized_versions ⇒ Object
- .primary_key ⇒ Object
- .table_exists? ⇒ Boolean
- .table_name ⇒ Object
Instance Method Summary collapse
Class Method Details
.all_versions ⇒ Object
36 37 38 |
# File 'lib/elasticsearch_record/schema_migration.rb', line 36 def all_versions order(:version).pluck(:version) end |
.create_table ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/elasticsearch_record/schema_migration.rb', line 16 def create_table unless connection.table_exists?(table_name) connection.create_table(table_name, id: false) do |t| t.string :version, **connection. end end end |
.drop_table ⇒ Object
24 25 26 |
# File 'lib/elasticsearch_record/schema_migration.rb', line 24 def drop_table connection.drop_table table_name, if_exists: true end |
.normalize_migration_number(number) ⇒ Object
28 29 30 |
# File 'lib/elasticsearch_record/schema_migration.rb', line 28 def normalize_migration_number(number) "%.3d" % number.to_i end |
.normalized_versions ⇒ Object
32 33 34 |
# File 'lib/elasticsearch_record/schema_migration.rb', line 32 def normalized_versions all_versions.map { |v| normalize_migration_number v } end |
.primary_key ⇒ Object
8 9 10 |
# File 'lib/elasticsearch_record/schema_migration.rb', line 8 def primary_key "version" end |
.table_exists? ⇒ Boolean
40 41 42 |
# File 'lib/elasticsearch_record/schema_migration.rb', line 40 def table_exists? connection.data_source_exists?(table_name) end |
.table_name ⇒ Object
12 13 14 |
# File 'lib/elasticsearch_record/schema_migration.rb', line 12 def table_name "#{table_name_prefix}#{schema_migrations_table_name}#{table_name_suffix}" end |
Instance Method Details
#version ⇒ Object
45 46 47 |
# File 'lib/elasticsearch_record/schema_migration.rb', line 45 def version super.to_i end |