Sha256: e0cfbb91fd24858c3b7cb2edd43db9fb87fd48fa9585ec1be48b84ef30f6466c

Contents?: true

Size: 985 Bytes

Versions: 2

Compression:

Stored size: 985 Bytes

Contents

require 'dm-migrations/sql/table'

module SQL
  module Sqlite3

    def supports_schema_transactions?
      true
    end

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

    def recreate_database
      DataMapper.logger.info "Dropping #{@uri.path}"
      system "rm #{@uri.path}"
      # do nothing, sqlite will automatically create the database file
    end

    def table_options
      ''
    end

    def supports_serial?
      true
    end

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

    class Column < SQL::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

2 entries across 2 versions & 1 rubygems

Version Path
dm-migrations-0.10.1 lib/dm-migrations/sql/sqlite3.rb
dm-migrations-0.10.0 lib/dm-migrations/sql/sqlite3.rb