مراية لـ
https://github.com/postalserver/postal.git
تم المزامنة 2025-12-01 05:43:04 +00:00
chore: silence message DB migrations during provisioning
هذا الالتزام موجود في:
@@ -1,5 +1,3 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# This file is auto-generated from the current state of the database. Instead
|
# This file is auto-generated from the current state of the database. Instead
|
||||||
# of editing this file, please use the migrations feature of Active Record to
|
# of editing this file, please use the migrations feature of Active Record to
|
||||||
# incrementally modify your database, and then regenerate this schema definition.
|
# incrementally modify your database, and then regenerate this schema definition.
|
||||||
|
|||||||
@@ -11,23 +11,28 @@ module Postal
|
|||||||
def up
|
def up
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.run(database, start_from = database.schema_version)
|
def self.run(database, start_from: database.schema_version, silent: false)
|
||||||
files = Dir[Rails.root.join("lib", "postal", "message_db", "migrations", "*.rb")]
|
files = Dir[Rails.root.join("lib", "postal", "message_db", "migrations", "*.rb")]
|
||||||
files = files.map do |f|
|
files = files.map do |f|
|
||||||
id, name = f.split("/").last.split("_", 2)
|
id, name = f.split("/").last.split("_", 2)
|
||||||
[id.to_i, name]
|
[id.to_i, name]
|
||||||
end.sort_by(&:first)
|
end.sort_by(&:first)
|
||||||
|
|
||||||
latest_version = files.last.first
|
latest_version = files.last.first
|
||||||
if latest_version > start_from
|
if latest_version <= start_from
|
||||||
puts "\e[32mMigrating #{database.database_name} from version #{start_from} => #{files.last.first}\e[0m"
|
puts "Nothing to do" unless silent
|
||||||
else
|
return false
|
||||||
puts "Nothing to do."
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
unless silent
|
||||||
|
puts "\e[32mMigrating #{database.database_name} from version #{start_from} => #{files.last.first}\e[0m"
|
||||||
|
end
|
||||||
|
|
||||||
files.each do |version, file|
|
files.each do |version, file|
|
||||||
klass_name = file.gsub(/\.rb\z/, "").camelize
|
klass_name = file.gsub(/\.rb\z/, "").camelize
|
||||||
next if start_from >= version
|
next if start_from >= version
|
||||||
|
|
||||||
puts "\e[45m++ Migrating #{klass_name} (#{version})\e[0m"
|
puts "\e[45m++ Migrating #{klass_name} (#{version})\e[0m" unless silent
|
||||||
require "postal/message_db/migrations/#{version.to_s.rjust(2, '0')}_#{file}"
|
require "postal/message_db/migrations/#{version.to_s.rjust(2, '0')}_#{file}"
|
||||||
klass = Postal::MessageDB::Migrations.const_get(klass_name)
|
klass = Postal::MessageDB::Migrations.const_get(klass_name)
|
||||||
instance = klass.new(database)
|
instance = klass.new(database)
|
||||||
|
|||||||
@@ -14,14 +14,14 @@ module Postal
|
|||||||
def provision
|
def provision
|
||||||
drop
|
drop
|
||||||
create
|
create
|
||||||
migrate
|
migrate(silent: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
# Migrate this database
|
# Migrate this database
|
||||||
#
|
#
|
||||||
def migrate(start_from = @database.schema_version)
|
def migrate(start_from: @database.schema_version, silent: false)
|
||||||
Postal::MessageDB::Migration.run(@database, start_from)
|
Postal::MessageDB::Migration.run(@database, start_from: start_from, silent: silent)
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|||||||
المرجع في مشكلة جديدة
حظر مستخدم