mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 07:34:40 +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
32 lines
784 B
Ruby
32 lines
784 B
Ruby
# frozen_string_literal: true
|
|
|
|
# This file is auto-generated from the IntermediateDB schema. To make changes,
|
|
# update the "config/intermediate_db.yml" configuration file and then run
|
|
# `bin/cli schema generate` to regenerate this file.
|
|
|
|
module Migrations::Database::IntermediateDB
|
|
module UserEmail
|
|
SQL = <<~SQL
|
|
INSERT INTO user_emails (
|
|
email,
|
|
created_at,
|
|
"primary",
|
|
user_id
|
|
)
|
|
VALUES (
|
|
?, ?, ?, ?
|
|
)
|
|
SQL
|
|
|
|
def self.create(email:, created_at:, primary: nil, user_id:)
|
|
::Migrations::Database::IntermediateDB.insert(
|
|
SQL,
|
|
email,
|
|
::Migrations::Database.format_datetime(created_at),
|
|
::Migrations::Database.format_boolean(primary),
|
|
user_id,
|
|
)
|
|
end
|
|
end
|
|
end
|