Sha256: 1290c0fae7af2275690a9b2891085174ce04bc832243be6df1642fde70b03e45

Contents?: true

Size: 1.05 KB

Versions: 5

Compression:

Stored size: 1.05 KB

Contents

module Ponytail
  class MigrationsController < ActionController::Base
    layout 'ponytail/application'

    def index
      @migrations = Migration.all
      @current_version = Migration.current_version
    end

    def new
      @migration = Migration.new
      @schema = Schema.new
    end

    def create
      @migration = Migration.new(migraion_params)

      if @migration.save
        redirect_to :migrations, notice: 'Migration was successfully created.'
      else
        @schema = Schema.new
        render action: :new
      end
    end

    def migrate
      if Migration.migrate
        redirect_to :migrations, notice: 'Migrate was succeed.'
      else
        redirect_to :migrations, notice: 'Migrate was failed.'
      end
    end

    def rollback
      if Migration.rollback
        redirect_to :migrations, notice: 'Rollback was succeed.'
      else
        redirect_to :migrations, notice: 'Rollback was failed.'
      end
    end

    private
    def migraion_params
      params.require(:ponytail_migration).permit(:name, :raw_content)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ponytail-0.2.0 app/controllers/ponytail/migrations_controller.rb
ponytail-0.1.0 app/controllers/ponytail/migrations_controller.rb
ponytail-0.0.5 app/controllers/ponytail/migrations_controller.rb
ponytail-0.0.4 app/controllers/ponytail/migrations_controller.rb
ponytail-0.0.3 app/controllers/ponytail/migrations_controller.rb