Sha256: e1f46bd57a992051c0fe2183495bc6c8ea4d8372a7327c957feb22ea5f6e4f12

Contents?: true

Size: 823 Bytes

Versions: 4

Compression:

Stored size: 823 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.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.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

4 entries across 4 versions & 1 rubygems

Version Path
decidim-core-0.14.1 db/migrate/20180611121852_change_newsletter_notification_type_value.rb
decidim-core-0.13.1 db/migrate/20180611121852_change_newsletter_notification_type_value.rb
decidim-core-0.13.0 db/migrate/20180611121852_change_newsletter_notification_type_value.rb
decidim-core-0.13.0.pre1 db/migrate/20180611121852_change_newsletter_notification_type_value.rb