class Dynamo::Record::TableMigration
Public Class Methods
add_stream(model)
click to toggle source
# File lib/dynamo/record/table_migration.rb, line 33 def self.add_stream(model) migrate_updates(model) do |migration| migration.update!( stream_specification: { stream_enabled: true, stream_view_type: 'NEW_IMAGE' } ) end rescue Aws::DynamoDB::Errors::ValidationException => e return e.message if e.message == 'Table already has an enabled stream' raise e end
migrate(model) { |migration| ... }
click to toggle source
# File lib/dynamo/record/table_migration.rb, line 14 def self.migrate(model) migration = Aws::Record::TableMigration.new(model) begin migration.client.describe_table(table_name: model.table_name) :exists rescue Aws::DynamoDB::Errors::ResourceNotFoundException yield migration migration.wait_until_available :migrated end end
migrate_table?(update_provisioned_throughput: false)
click to toggle source
# File lib/dynamo/record/table_migration.rb, line 48 def self.migrate_table?(update_provisioned_throughput: false) unless update_provisioned_throughput table_name = table_config.instance_values['model_class'].table_name described_table = table_config.client.describe_table table_name: table_name provisioned_throughput = described_table.table.provisioned_throughput table_config.read_capacity_units provisioned_throughput.read_capacity_units table_config.write_capacity_units provisioned_throughput.write_capacity_units end !table_config.exact_match? rescue Aws::DynamoDB::Errors::ResourceNotFoundException true end
migrate_updates(model) { |migration| ... }
click to toggle source
# File lib/dynamo/record/table_migration.rb, line 26 def self.migrate_updates(model) migration = Aws::Record::TableMigration.new(model) yield migration migration.wait_until_available :updated end
table_config_check()
click to toggle source
# File lib/dynamo/record/table_migration.rb, line 6 def self.table_config_check if migrate_table? table_config.migrate! return :migrated end :exists end