Sha256: 4b8ded7f35ab6e700dd49e4e577fec9ddca898fbe85a6ed4152feb41bda3b9be

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 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 :notes do |t|
	  t.string :title
          t.string :book
          t.string :stack
	  t.integer :content_length
          t.timestamps
	  t.belongs_to :batch
	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, :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.2 lib/yinx_sql.rb