Sha256: 2bbe81ea49b9398c609c661546cd794e88af86aaa13ef40dbd6504aeb9ad6253

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

require "yinx_sql/version"
require 'active_record'
require 'yinx'
require 'yinx_sql/batch'
require 'yinx_sql/json_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.1 lib/yinx_sql.rb