Sha256: a6c66d52e975d283ac8a48756e876c1990c36e90d5c599181c2dce4e6fb16e2e

Contents?: true

Size: 1.1 KB

Versions: 12

Compression:

Stored size: 1.1 KB

Contents

require File.dirname(__FILE__) + '/table'

module SQL
  module Mysql

    def supports_schema_transactions?
      false
    end

    def table(table_name)
      SQL::Mysql::Table.new(self, table_name)
    end

    def recreate_database
      execute "DROP DATABASE #{db_name}"
      execute "CREATE DATABASE #{db_name}"
      execute "USE #{db_name}"
    end

    def supports_serial?
      true
    end

    # TODO: move to dm-more/dm-migrations
    def property_schema_statement(schema)
      if supports_serial? && schema[:serial]
        statement = "#{schema[:quote_column_name]} serial PRIMARY KEY"
      else
        super
      end
    end

    class Table
      def initialize(adapter, table_name)
        @columns = []
        adapter.query_table(table_name).each do |col_struct|
          @columns << SQL::Mysql::Column.new(col_struct)
        end
      end
    end

    class Column
      def initialize(col_struct)
        @name, @type, @default_value, @primary_key = col_struct.name, col_struct.type, col_struct.dflt_value, col_struct.pk

        @not_null = col_struct.notnull == 0
      end
    end


  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
dm-migrations-0.9.2 lib/sql/mysql.rb
dm-migrations-0.9.10 lib/sql/mysql.rb
dm-migrations-0.9.6 lib/sql/mysql.rb
dm-migrations-0.9.3 lib/sql/mysql.rb
dm-migrations-0.9.4 lib/sql/mysql.rb
dm-migrations-0.9.5 lib/sql/mysql.rb
dm-migrations-0.9.7 lib/sql/mysql.rb
dm-migrations-0.9.8 lib/sql/mysql.rb
dm-migrations-0.9.9 lib/sql/mysql.rb
mack-data_mapper-0.8.2 lib/gems/dm-migrations-0.9.7/lib/sql/mysql.rb
mack-data_mapper-0.8.3.1 lib/gems/dm-migrations-0.9.9/lib/sql/mysql.rb
mack-data_mapper-0.8.3 lib/gems/dm-migrations-0.9.9/lib/sql/mysql.rb