require 'carto/db/migration_helper'

include Carto::Db::MigrationHelper

migration(
  Proc.new do
    create_table :oauth_apps do
      Uuid        :id, primary_key: true, default: 'uuid_generate_v4()'.lit
      foreign_key :user_id, :users, type: :uuid, null: false, index: true, on_delete: :restrict
      String      :name, null: false
      DateTime    :created_at, null: false, default: Sequel::CURRENT_TIMESTAMP
      DateTime    :updated_at, null: false, default: Sequel::CURRENT_TIMESTAMP
      # Oauth parameters
      String      :client_id, unique: true, null: false
      String      :client_secret, null: false
      String      :redirect_uri, null: false
    end
  end,
  Proc.new do
    drop_table :oauth_apps
  end
)

require 'carto/db/migration_helper'

include Carto::Db::MigrationHelper

migration(
  Proc.new do
    create_table :oauth_apps do
      Uuid        :id, primary_key: true, default: 'uuid_generate_v4()'.lit
      foreign_key :user_id, :users, type: :uuid, null: false, index: true, on_delete: :restrict
      String      :name, null: false
      DateTime    :created_at, null: false, default: Sequel::CURRENT_TIMESTAMP
      DateTime    :updated_at, null: false, default: Sequel::CURRENT_TIMESTAMP
      # Oauth parameters
      String      :client_id, unique: true, null: false
      String      :client_secret, null: false
      String      :redirect_url, null: false
    end
  end,
  Proc.new do
    drop_table :oauth_apps
  end
)

Support a single redirection uri
Support a single redirection uri
