class CreateDefaultDsn < ActiveRecord::Migration[8.1]
  def change
    reversible do |dir|
      dir.up do
        # Only create if no DSNs exist
        if Dsn.count == 0
          Dsn.create!(
            name: 'Development DSN',
            key: 'dev-test-key-1234567890abcdef',
            enabled: true
          )
        end
      end
      dir.down do
        # Remove the default DSN if it exists
        Dsn.where(key: 'dev-test-key-1234567890abcdef').delete_all
      end
    end
  end
end
