mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-21 23:19:22 +08:00
* Splits the existing script into multiple classes * Adds command for generating IntermediateDB schema (`migrations/bin/cli schema generate`) * Changes the syntax of the IntermediateDB schema config * Adds validation for the schema config * It uses YAML schema aka JSON schema to validate the config file * It generates the SQL schema file and Ruby classes for storing data in the IntermediateDB
29 lines
695 B
Ruby
Vendored
29 lines
695 B
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
module Migrations::Database::IntermediateDB
|
|
module UserSuspension
|
|
SQL = <<~SQL
|
|
INSERT INTO user_suspensions (
|
|
user_id,
|
|
suspended_at,
|
|
suspended_till,
|
|
suspended_by_id,
|
|
reason
|
|
)
|
|
VALUES (
|
|
?, ?, ?, ?, ?
|
|
)
|
|
SQL
|
|
|
|
def self.create(user_id:, suspended_at:, suspended_till: nil, suspended_by_id: nil, reason: nil)
|
|
::Migrations::Database::IntermediateDB.insert(
|
|
SQL,
|
|
user_id,
|
|
::Migrations::Database.format_datetime(suspended_at),
|
|
::Migrations::Database.format_datetime(suspended_till),
|
|
suspended_by_id,
|
|
reason,
|
|
)
|
|
end
|
|
end
|
|
end
|