# frozen_string_literal: true

class AddReadedCountDefault < ActiveRecord::Migration
  def up
    change_column_default :ads, :readed_count, 0
  end

  def down
    change_column_default :ads, :readed_count, nil
  end
end

# frozen_string_literal: true

class AddReadedCountDefault < ActiveRecord::Migration
  def up
    change_column_default :ads, :readed_count, 0

    execute 'UPDATE ads SET readed_count = 0 WHERE readed_count IS NULL'
  end

  def down
    change_column_default :ads, :readed_count, nil

    execute 'UPDATE ads SET readed_count = NULL WHERE readed_count = 0'
  end
end

Complete readed count default change
Complete readed count default change

This was an overlook on my part. I should've changed existing defaults in
the migration. I run it manually after deployment, but I'm adding it here
for completeness.
