Sha256: ffae89c074a6b68529dd514f1626b38ca61c1382be443b434008054e7d777a13

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

require "yinx_sql/version"
require 'active_record'
require 'yinx'
require 'yinx_sql/batch'

module Yinx
  module SQL

    def self.connect *args
      ActiveRecord::Base.establish_connection *args
    end

    class Tables < ActiveRecord::Migration
      def up
        create_table :batches do |t|
          t.timestamps
        end

	create_table :tags do |t|
	  t.string :name
	  t.belongs_to :batch
	end

	create_table :stacks do |t|
	  t.string :name
	  t.belongs_to :batch
	end

	create_table :books do |t|
	  t.string :name
	  t.belongs_to :stack
	  t.belongs_to :batch
	end

	create_table :notes do |t|
	  t.string :title
	  t.integer :content_length
          t.timestamps
	  t.belongs_to :book
	end

        create_table :notes_tags do |t|
          t.belongs_to :note, index: true
          t.belongs_to :tag, index: true
        end
      end

      def down
	[:notes_tags, :notes, :books, :stacks, :tags, :batches].each do |t|
	  drop_table t
	end
      end
    end

    class Json < ActiveRecord::Migration
      def up
        create_table :json_batches do |t|
          t.jsonb :batch, default: '[]'
        end
      end

      def down
        drop_table :json_batched
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
yinx_sql-0.1.0 lib/yinx_sql.rb