Sha256: ee5661e1a63cc91a15477efb026cf6b13cbaf42659e09fbcf6bee10df56eff70

Contents?: true

Size: 891 Bytes

Versions: 77

Compression:

Stored size: 891 Bytes

Contents

# frozen_string_literal: true

class ChangeNewsletterNotificationTypeValue < ActiveRecord::Migration[5.2]
  class User < ApplicationRecord
    self.table_name = :decidim_users
  end

  def up
    add_column :decidim_users, :newsletter_token, :string, default: ""
    add_column :decidim_users, :newsletter_notifications_at, :datetime
    User.reset_column_information
    User.where(newsletter_notifications: true).update(newsletter_notifications_at: Time.zone.parse("2018-05-24 00:00 +02:00"))
    remove_column :decidim_users, :newsletter_notifications
  end

  def down
    add_column :decidim_users, :newsletter_notifications, :boolean
    User.reset_column_information
    User.where.not(newsletter_notifications_at: nil).update(newsletter_notifications: true)
    remove_column :decidim_users, :newsletter_notifications_at
    remove_column :decidim_users, :newsletter_token
  end
end

Version data entries

77 entries across 77 versions & 1 rubygems

Version Path
decidim-core-0.26.8 db/migrate/20180611121852_change_newsletter_notification_type_value.rb
decidim-core-0.27.4 db/migrate/20180611121852_change_newsletter_notification_type_value.rb
decidim-core-0.27.3 db/migrate/20180611121852_change_newsletter_notification_type_value.rb
decidim-core-0.26.7 db/migrate/20180611121852_change_newsletter_notification_type_value.rb
decidim-core-0.26.5 db/migrate/20180611121852_change_newsletter_notification_type_value.rb
decidim-core-0.27.2 db/migrate/20180611121852_change_newsletter_notification_type_value.rb
decidim-core-0.27.1 db/migrate/20180611121852_change_newsletter_notification_type_value.rb
decidim-core-0.26.4 db/migrate/20180611121852_change_newsletter_notification_type_value.rb
decidim-core-0.27.0 db/migrate/20180611121852_change_newsletter_notification_type_value.rb
decidim-core-0.26.3 db/migrate/20180611121852_change_newsletter_notification_type_value.rb
decidim-core-0.27.0.rc2 db/migrate/20180611121852_change_newsletter_notification_type_value.rb
decidim-core-0.27.0.rc1 db/migrate/20180611121852_change_newsletter_notification_type_value.rb
decidim-core-0.26.2 db/migrate/20180611121852_change_newsletter_notification_type_value.rb
decidim-core-0.26.1 db/migrate/20180611121852_change_newsletter_notification_type_value.rb
decidim-core-0.26.0 db/migrate/20180611121852_change_newsletter_notification_type_value.rb
decidim-core-0.26.0.rc2 db/migrate/20180611121852_change_newsletter_notification_type_value.rb
decidim-core-0.26.0.rc1 db/migrate/20180611121852_change_newsletter_notification_type_value.rb
decidim-core-0.25.2 db/migrate/20180611121852_change_newsletter_notification_type_value.rb
decidim-core-0.25.1 db/migrate/20180611121852_change_newsletter_notification_type_value.rb
decidim-core-0.25.0 db/migrate/20180611121852_change_newsletter_notification_type_value.rb