Sha256: 2f88dd24777edb4cae6f9dd99de19528033112ec8450f25bc7e252c82cd8cc4d

Contents?: true

Size: 723 Bytes

Versions: 3

Compression:

Stored size: 723 Bytes

Contents

require 'skr/db/migration_helpers'

class CreateCustomerProjectDetailsViews < ActiveRecord::Migration

    def up
        execute <<-EOS
        create view #{view} as
          select
            cp.id as skr_customer_project_id,
            c.code as customer_code,
            c.name as customer_description,
            s.code as sku_code,
            s.description as sku_description

          from #{skr_prefix}customer_projects cp
            join #{skr_prefix}skus s on s.id=cp.sku_id
            join #{skr_prefix}customers c on c.id=cp.customer_id
        EOS
    end

    def down
        execute "drop view #{view}"
    end

  private

    def view
        "#{skr_prefix}customer_project_details"
    end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
stockor-0.4.0 db/migrate/20151121211323_create_customer_project_details_views.rb
stockor-0.3.0 db/migrate/20151121211323_create_customer_project_details_views.rb
stockor-0.2 db/migrate/20151121211323_create_customer_project_details_views.rb