Class: Gitlab::Database::Migrations::BatchedMigrationLastId
- Inherits:
-
Object
- Object
- Gitlab::Database::Migrations::BatchedMigrationLastId
- Defined in:
- lib/gitlab/database/migrations/batched_migration_last_id.rb
Constant Summary collapse
- FILE_NAME =
'last-batched-background-migration-id.txt'
Instance Method Summary collapse
-
#initialize(connection, base_dir) ⇒ BatchedMigrationLastId
constructor
A new instance of BatchedMigrationLastId.
-
#read ⇒ Integer?
Reads the last id from the file.
- #store ⇒ Object
Constructor Details
#initialize(connection, base_dir) ⇒ BatchedMigrationLastId
Returns a new instance of BatchedMigrationLastId.
9 10 11 12 |
# File 'lib/gitlab/database/migrations/batched_migration_last_id.rb', line 9 def initialize(connection, base_dir) @connection = connection @base_dir = base_dir end |
Instance Method Details
#read ⇒ Integer?
Reads the last id from the file
28 29 30 31 32 |
# File 'lib/gitlab/database/migrations/batched_migration_last_id.rb', line 28 def read return unless File.exist?(file_path) Integer(File.read(file_path).presence, exception: false) end |
#store ⇒ Object
14 15 16 |
# File 'lib/gitlab/database/migrations/batched_migration_last_id.rb', line 14 def store File.open(file_path, 'wb') { |file| file.write(last_background_migration_id) } end |