From 62dfa5ff456388a9b3b6a23ff7f87eacbb5c9e04 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 18 Sep 2007 23:06:40 +0000 Subject: [PATCH] Make the tile ID column unsigned as intended. --- db/migrate/005_tile_tracepoints.rb | 2 +- lib/migrate.rb | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/db/migrate/005_tile_tracepoints.rb b/db/migrate/005_tile_tracepoints.rb index d9d782df0..246f9b7b4 100644 --- a/db/migrate/005_tile_tracepoints.rb +++ b/db/migrate/005_tile_tracepoints.rb @@ -1,6 +1,6 @@ class TileTracepoints < ActiveRecord::Migration def self.up - add_column "gps_points", "tile", :integer, :null => false, :options => "UNSIGNED" + add_column "gps_points", "tile", :integer, :null => false, :unsigned => true add_index "gps_points", ["tile"], :name => "points_tile_idx" remove_index "gps_points", :name => "points_idx" diff --git a/lib/migrate.rb b/lib/migrate.rb index c31e31538..1d32d175d 100644 --- a/lib/migrate.rb +++ b/lib/migrate.rb @@ -17,6 +17,14 @@ module ActiveRecord return false if options[:options] =~ /AUTO_INCREMENT/i return old_options_include_default?(options) end + + alias_method :old_add_column_options!, :add_column_options! + + def add_column_options!(sql, options) + sql << " UNSIGNED" if options[:unsigned] + old_add_column_options!(sql, options) + sql << " #{options[:options]}" + end end class MysqlAdapter @@ -40,7 +48,6 @@ module ActiveRecord change_column_sql = "ALTER TABLE #{table_name} CHANGE #{column_name} #{column_name} #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}" add_column_options!(change_column_sql, options) - change_column_sql << " #{options[:options]}" execute(change_column_sql) end -- 2.39.5