mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-11-28 09:24:24 +01:00
(bug) unable to run rails db:migrate if the database is empty
This commit is contained in:
parent
2ea4296e3c
commit
8a308953b7
@ -2,6 +2,8 @@
|
||||
|
||||
## Next release
|
||||
|
||||
- Fix a bug: unable to run rails db:migrate if the database is empty
|
||||
|
||||
## v6.3.34 2024 October 21
|
||||
|
||||
- Fix a bug: unable to run open project update task
|
||||
|
@ -3,6 +3,8 @@
|
||||
class MigrateSettingsValueToHistoryValues < ActiveRecord::Migration[4.2]
|
||||
def up
|
||||
user = User.admins.first
|
||||
return unless user
|
||||
|
||||
Setting.all.each do |setting|
|
||||
hv = HistoryValue.new(
|
||||
setting: setting,
|
||||
|
@ -96,6 +96,7 @@ class CreateNotificationTypes < ActiveRecord::Migration[5.2]
|
||||
|
||||
add_index :notification_types, :name, unique: true
|
||||
|
||||
if NotificationType.count > 0
|
||||
# Records previous notification types
|
||||
NOTIFICATIONS_TYPES.each do |notification_type|
|
||||
NotificationType.create!(
|
||||
@ -108,6 +109,7 @@ class CreateNotificationTypes < ActiveRecord::Migration[5.2]
|
||||
|
||||
last_id = NotificationType.order(:id).last.id
|
||||
execute "SELECT setval('public.notification_types_id_seq', #{last_id})"
|
||||
end
|
||||
|
||||
add_foreign_key :notifications, :notification_types
|
||||
end
|
||||
|
@ -36,6 +36,7 @@ class AddLabelI18nPathToStatisticTables < ActiveRecord::Migration[7.0]
|
||||
|
||||
# StatisticField
|
||||
|
||||
if StatisticField.count > 0
|
||||
StatisticField.find_by!(key: 'groupName', statistic_index_id: statistic_index_subscription.id).update!(label: nil, label_i18n_path: 'statistics.group')
|
||||
|
||||
StatisticField.find_by!(key: 'spaceDates', statistic_index_id: statistic_index_space.id).update!(label: nil, label_i18n_path: 'statistics.space_dates')
|
||||
@ -68,8 +69,10 @@ class AddLabelI18nPathToStatisticTables < ActiveRecord::Migration[7.0]
|
||||
StatisticField.find_by!(key: 'userId', statistic_index_id: statistic_index_user.id).update!(label: nil, label_i18n_path: 'statistics.user_id')
|
||||
|
||||
StatisticField.find_by!(key: 'groupName', statistic_index_id: statistic_index_order.id).update!(label: nil, label_i18n_path: 'statistics.group')
|
||||
end
|
||||
|
||||
# StatisticType
|
||||
if StatisticType.count > 0
|
||||
StatisticType.find_by!(key: 'booking', statistic_index_id: statistic_index_machine.id).update!(label: nil, label_i18n_path: 'statistics.bookings')
|
||||
StatisticType.find_by!(key: 'hour', statistic_index_id: statistic_index_machine.id).update!(label: nil, label_i18n_path: 'statistics.hours_number')
|
||||
|
||||
@ -89,11 +92,14 @@ class AddLabelI18nPathToStatisticTables < ActiveRecord::Migration[7.0]
|
||||
StatisticType.find_by!(key: 'hour', statistic_index_id: statistic_index_space.id).update!(label: nil, label_i18n_path: 'statistics.hours_number')
|
||||
|
||||
StatisticType.find_by!(key: 'store', statistic_index_id: statistic_index_order.id).update!(label: nil, label_i18n_path: 'statistics.store')
|
||||
end
|
||||
|
||||
# StatisticSubType
|
||||
if StatisticSubType.count > 0
|
||||
StatisticSubType.find_by!(key: 'created').update!(label: nil, label_i18n_path: 'statistics.account_creation')
|
||||
StatisticSubType.find_by!(key: 'published').update!(label: nil, label_i18n_path: 'statistics.project_publication')
|
||||
StatisticSubType.find_by!(key: 'paid-processed').update!(label: nil, label_i18n_path: 'statistics.paid-rocessed')
|
||||
StatisticSubType.find_by!(key: 'aborted').update!(label: nil, label_i18n_path: 'statistics.aborted')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user