similar to: Migration, BigInts, and string lengths

Displaying 20 results from an estimated 1000 matches similar to: "Migration, BigInts, and string lengths"

2006 Jul 01
1
Changing column to NOT NULL with migration silently failing.
Hi I''ve created a migration called make_customer_type_id_not_null_for_customers. The migration .rb file looks like this: class MakeCustomerTypeIdNotNullForCustomers < ActiveRecord::Migration def self.up change_column(:customers, :customer_type_id, :integer, { :null => false }) end def self.down change_column(:customers, :customer_type_id, :integer, { :null =>
2006 Oct 31
4
Auto-increment lost during migration.
Hi. I get some strange results when using rename_column on a primary key in a migration. It seems like the migration script removes the auto-increment property if you rename a column. This is a minimal example. create_table :foo, :primary_key => :foo_id do |t| t.column "name", :string end # renaming the primary key makes auto-increment disappear. rename_column
2006 Aug 02
2
mangle ActiveRecord
Dear Gurus on Rails! How do I change the behaviour of one method in ActiveRecord::ConnectionAdapters::SchemaStatements ? Full story: I''d like to mangle ActiveRecord::ConnectionAdapters::SchemaStatements so when it creates a new sql table, it also (optionally) creates my created_at, deleted, key_id, session_id etc columns that I use on basically all tables. It would not be DRY to repeat
2006 Jan 09
2
Using SQL to get a whole record when using aggregate functions
I have a table with some data structured something like this: book ---- title (varchar) pages (int) completed_on (date) While I can find the shortest book completed in each year with something like this: select min( pages ), year from book group by year I would also like to get the title of the shortest book in each year. Is there any way to do this by modifying the previous query to pull
2008 Jan 19
1
Decimals are being converted to Bigdecimals!!!!!
Hi all, I''m working on a financial app, and have set up some columns in my tables as decimals with precision => 8 and scale => 2. My migration looks like: change_column :lineitems, :price, :decimal, :precision => 8, :scale => 2 change_column :payments, :amount, :decimal, :precision => 8, :scale => 2 I''ve run the migration and restarted the server. I
2012 Mar 02
2
Change DB data type and limited decimals
Rails3.1.3 I have db type, startp:integer I need to change it to float. More specifically, 1.2, 45.1, 143.8 ... I have two questions: 1. Is removing and adding the field through migration the only way? in other words, is there a single command to change the type? 2. Is there anyway to limit the decimal place to only one? 56.3, 34.2... are acceptable, but 23.112, 77.34, ... are
2012 May 25
2
Typecast values on change_column for postgresql
Hello, Currently if you have a string column that have only number values (think a year column using string by mistake) and you want to change to integer, you can''t. If you apply this monkey-patch will be possible: https://gist.github.com/1393441 Note: if some value can''t be casted by postgresql (if have a letter for example), the migration will fail as expected. I think
2006 Jul 12
1
Dumping schema
All, It looks like rake db:schema:dump does not dump primary keys. I have some legacy table that don''t follow the convention ie pk = id and none of the primary keys for these tables are getting dumped... Seems strange as this should be readily available from the db. I am using MySQL. Is anybody else seeing that ? Incidentally how does one specify a primary key using
2008 Feb 26
5
Rails 2.0.2 MySQL 'year' datatype missing from ActiveRecord?
Hi all, This is my first post to the forum, and I''ll point out right away that I''m a noob to everything, Ruby, Rails, MySQL, etc., so I expect that I''m wrong here, but is the ''year'' datatype missing from ActiveRecord in 2.0.2? According to my MySQL 5.0 reference manual, ''year'' is a datatype, but when I try to run a migration that has
2010 Apr 03
2
Specifying a decimal field precision/scale with scaffold requires 2 steps?
Hi, It appears to me that the command: ruby script/generate scaffold whatever money_field:decimal(10,2) will not generate a valid migration. Therefore it appears to me only two ways to achieve the desired result is: 1.1 Omit the the precision/scale on the scaffold command 1.2 Edit the migration file by following the "do |t| ... end" with the command: change_column :whatever
2006 Nov 13
1
Removing column default with a migration
Hi guys, I''m having problems removing the default from a boolean field. I''m using the following statement: change_column :valuations, :too_many_adults, :integer, :null => true but it''s adding DEFAULT ''0'' to the SQL statement. I''m having no luck using change_column_default either. Is this possible? Gareth
2006 Jan 02
2
HTML Fragment not Loading in Firefox; Fine Elsewhere
Ok, this has got me going a bit crazy. I have an HTML fragment being returned for the result to an AJAX query. It works fine in Safari or from curl (and even in IE/Mac), but utterly fails to load in Firefox, even if I point directly to the URL, skipping all that AJAX stuff in between. (The server logs show a 200 response, regardless of which browser is being used.) I''ve verified
2009 Jul 24
2
[PATCH server] add collapsable sections to vm form
the vm form is getting cluttered, this patch simply add collapsable sections to the form, making the 'storage' and 'network' sections collapsed by default credit goes to jayg for contributing alot to this patch in terms of simplification and cleanup --- src/app/helpers/application_helper.rb | 4 +- src/app/views/vm/_form.rhtml | 35 ++++++++++++++++++++++----------
2001 Sep 24
3
reading in ASCII files
I wonder if there is a way to read in CSV files so that - certain fields within each record (line) are ignored, i.e. not converted to columns in the output data frame - factors/levels are created automatically: often, the possible labels are known in advance and could immediately be converted. This would save a lot of memory and time for bigger files, I assume. Johann
2007 Mar 28
1
Migration w/change_column fails on MySQL 5.1
All, I have a migration with statements like this: change_column :quote_input_class_codes, :employee_payroll, :integer, :default => 0, :null => false When I migrate, I get: (in C:/eclipse/workspace/OnlineRating) == DefaultQiccPayrollsToZero: migrating ======================================= -- change_column(:quote_input_class_codes, :employee_payroll, :integer, {:null=>false,
2009 Sep 28
5
Multi-databases support
Hi, While I was hacking ovirt-server, I have found that it's currently restricted to Postgres DB. Even if I like postgres for serious work on a server, I really prefer to hack/dev locally on a Sqlite or MySQL DB. I have googled on rails in order to find a good answer for the "foreign key problem" which forces OVirt to stay on pg. I have found a plugin on this particular
2005 Dec 27
1
Odd Behavior with render
I''d been trying to iterate through an array of hashes using the ActionController''s render method. Unfortunately, it appears that when I use a hash as one of the array elements, it gets passed as a nil to the partial. Here''s some code: @books = [ ''hello'', ''hello2'' ] render :partial => "book",
2006 Apr 19
6
undefined method `create_table'' for #<LoginController:0x5e60
I am geeting the foolowing error. undefined method `create_table'' for #<LoginController:0x5e60110> I wrote the crete action in application controller. I am coping ther total worng please help me! class ApplicationController < ActionController::Base model :cart model :line_item before_filter :authorize def create # create_table() yields a TableDefinition instance
2005 Dec 28
4
AJAX works in Safari, broken in Firefox
I''ve been working on an AJAX search, very similar to the Flickr one in the screencast linked from the main rails page. I''ve been doing my testing in Safari, where everything has worked fine, only to now discover the results of the search action seem disinclined to load in Firefox. I can enter a URL to return the HTML fragment that''s supposed to be dropped into
2009 Jun 19
1
[PATCH server] add collapsable sections to vm form
the vm form is getting cluttered, this patch simply add collapsable sections to the form, making the 'storage' and 'network' sections collapsed by default --- src/app/helpers/application_helper.rb | 9 +++++ src/app/views/vm/_form.rhtml | 55 +++++++++++++++++++++++++-------- src/public/javascripts/ovirt.js | 25 +++++++++++++++