Files
discourse/migrations/lib/database/intermediate_db/user_email.rb
Gerhard Schlager 17ba19c7ae REFACTOR: Code generator for migrations IntemerdiateDB
* 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
2025-04-07 17:22:36 +02:00

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