mirror of
https://github.com/discourse/discourse.git
synced 2025-06-16 12:11:32 +08:00

By default, rails makes timestamp columns (`created_at` and `updated_at`) non-nullable, we also have some required core and plugins columns we wouldn't necessarily want to enforce in the intermediate DB schema. It'll be better to set the default values for these during import instead of enforcing these at the converter level. This change adds support for globally modifying a column’s `nullable` state, defaulting all `created_at` columns to be `nullable` while allowing for table level overrides. --------- Co-authored-by: Gerhard Schlager <gerhard.schlager@discourse.org>
32 lines
788 B
Ruby
32 lines
788 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: nil, 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
|