mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 11:48:08 +08:00
DEV: Refactor migrations-tooling
* Updates GitHub Action for migrations * Rubocop: Always `EnforcedShorthandSyntax` for hashes in the `migrations` directory * Automatically load all available converter steps * Enable YJIT at runtime, if available * Progressbar shows skipped records and other small improvements
This commit is contained in:

committed by
Gerhard Schlager

parent
7b5839ec44
commit
71a90dcba2
@ -11,7 +11,7 @@ module Migrations::Database::IntermediateDB
|
||||
VALUES (?, ?, ?, ?, ?)
|
||||
SQL
|
||||
|
||||
def self.create!(created_at: Time.now, type:, message:, exception: nil, details: nil)
|
||||
def self.create(created_at: Time.now, type:, message:, exception: nil, details: nil)
|
||||
::Migrations::Database::IntermediateDB.insert(
|
||||
SQL,
|
||||
::Migrations::Database.format_datetime(created_at),
|
||||
|
@ -17,76 +17,79 @@ module Migrations::Database::IntermediateDB
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
SQL
|
||||
|
||||
class << self
|
||||
def create_for_file!(
|
||||
def self.create_for_file(
|
||||
path:,
|
||||
filename: nil,
|
||||
type: nil,
|
||||
description: nil,
|
||||
origin: nil,
|
||||
user_id: nil
|
||||
)
|
||||
create(
|
||||
id: ::Migrations::ID.hash(path),
|
||||
filename: filename || File.basename(path),
|
||||
path:,
|
||||
filename: nil,
|
||||
type: nil,
|
||||
description: nil,
|
||||
origin: nil,
|
||||
user_id: nil
|
||||
type:,
|
||||
description:,
|
||||
origin:,
|
||||
user_id:,
|
||||
)
|
||||
create!(
|
||||
id: ::Migrations::ID.hash(path),
|
||||
filename: filename || File.basename(path),
|
||||
path:,
|
||||
type:,
|
||||
description:,
|
||||
origin:,
|
||||
user_id:,
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def create_for_url!(url:, filename:, type: nil, description: nil, origin: nil, user_id: nil)
|
||||
create!(
|
||||
id: ::Migrations::ID.hash(url),
|
||||
filename:,
|
||||
url:,
|
||||
type:,
|
||||
description:,
|
||||
origin:,
|
||||
user_id:,
|
||||
)
|
||||
end
|
||||
|
||||
def create_for_data!(data:, filename:, type: nil, description: nil, origin: nil, user_id: nil)
|
||||
create!(
|
||||
id: ::Migrations::ID.hash(data),
|
||||
filename:,
|
||||
data: ::Migrations::Database.to_blob(data),
|
||||
type:,
|
||||
description:,
|
||||
origin:,
|
||||
user_id:,
|
||||
)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def create!(
|
||||
id:,
|
||||
def self.create_for_url(url:, filename:, type: nil, description: nil, origin: nil, user_id: nil)
|
||||
create(
|
||||
id: ::Migrations::ID.hash(url),
|
||||
filename:,
|
||||
path: nil,
|
||||
data: nil,
|
||||
url: nil,
|
||||
type: nil,
|
||||
description: nil,
|
||||
origin: nil,
|
||||
user_id: nil
|
||||
url:,
|
||||
type:,
|
||||
description:,
|
||||
origin:,
|
||||
user_id:,
|
||||
)
|
||||
end
|
||||
|
||||
def self.create_for_data(
|
||||
data:,
|
||||
filename:,
|
||||
type: nil,
|
||||
description: nil,
|
||||
origin: nil,
|
||||
user_id: nil
|
||||
)
|
||||
create(
|
||||
id: ::Migrations::ID.hash(data),
|
||||
filename:,
|
||||
data: ::Migrations::Database.to_blob(data),
|
||||
type:,
|
||||
description:,
|
||||
origin:,
|
||||
user_id:,
|
||||
)
|
||||
end
|
||||
|
||||
def self.create(
|
||||
id:,
|
||||
filename:,
|
||||
path: nil,
|
||||
data: nil,
|
||||
url: nil,
|
||||
type: nil,
|
||||
description: nil,
|
||||
origin: nil,
|
||||
user_id: nil
|
||||
)
|
||||
::Migrations::Database::IntermediateDB.insert(
|
||||
SQL,
|
||||
id,
|
||||
filename,
|
||||
path,
|
||||
data,
|
||||
url,
|
||||
type,
|
||||
description,
|
||||
origin,
|
||||
user_id,
|
||||
)
|
||||
::Migrations::Database::IntermediateDB.insert(
|
||||
SQL,
|
||||
id,
|
||||
filename,
|
||||
path,
|
||||
data,
|
||||
url,
|
||||
type,
|
||||
description,
|
||||
origin,
|
||||
user_id,
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user