2019-05-02 17:17:27 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-02-17 00:47:47 -06:00
|
|
|
module FreedomPatches
|
|
|
|
module SchemaMigrationDetails
|
|
|
|
def exec_migration(conn, direction)
|
|
|
|
rval = nil
|
|
|
|
|
2023-01-09 06:10:19 -06:00
|
|
|
time = Benchmark.measure { rval = super }
|
2016-02-17 00:47:47 -06:00
|
|
|
|
|
|
|
sql = <<SQL
|
|
|
|
INSERT INTO schema_migration_details(
|
|
|
|
version,
|
|
|
|
hostname,
|
|
|
|
name,
|
|
|
|
git_version,
|
|
|
|
duration,
|
|
|
|
direction,
|
|
|
|
rails_version,
|
|
|
|
created_at
|
|
|
|
) values (
|
|
|
|
:version,
|
|
|
|
:hostname,
|
|
|
|
:name,
|
|
|
|
:git_version,
|
|
|
|
:duration,
|
|
|
|
:direction,
|
|
|
|
:rails_version,
|
|
|
|
:created_at
|
|
|
|
)
|
|
|
|
SQL
|
|
|
|
|
2020-02-17 22:11:30 -06:00
|
|
|
hostname = Discourse.os_hostname
|
2023-01-09 06:10:19 -06:00
|
|
|
sql =
|
|
|
|
ActiveRecord::Base.public_send(
|
|
|
|
:sanitize_sql_array,
|
|
|
|
[
|
|
|
|
sql,
|
|
|
|
{
|
|
|
|
version: version || "",
|
|
|
|
duration: (time.real * 1000).to_i,
|
|
|
|
hostname: hostname,
|
|
|
|
name: name,
|
|
|
|
git_version: Discourse.git_version,
|
|
|
|
created_at: Time.zone.now,
|
|
|
|
direction: direction.to_s,
|
|
|
|
rails_version: Rails.version,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
)
|
2016-02-17 00:47:47 -06:00
|
|
|
|
|
|
|
conn.execute(sql)
|
|
|
|
|
|
|
|
rval
|
|
|
|
end
|
|
|
|
|
2022-04-05 05:08:28 -05:00
|
|
|
ActiveRecord::Migration.prepend(self)
|
2016-02-17 00:47:47 -06:00
|
|
|
end
|
|
|
|
end
|