similar to: Migration with foreign key won''t work

Displaying 8 results from an estimated 8 matches similar to: "Migration with foreign key won''t work"

2005 Dec 05
0
bug in bubbleshare's Active Record extensions?
I''m using add_foreign_key_constraint and remove_foreign_key_constraint from Bubbleshare''s Active Records Extension plugin now to manage the foreign key relationships I describe in my other recent posting. The constraints get added within migrations, but I''m running into two problems (Rails 0.14.3, PostgreSQL db): 1. Dumping the schema doesn''t dump the
2006 Apr 27
3
Removing a default value for a foreign key with not null set
Hi all, For various reasons I need to have foreign keys with not null constraints. Eg: create_table :people do |t| t.column :name, :string t.column :household_id, :integer, :null => false end create_table :households do |t| t.column :name, :string end add_foreign_key_constraint :people, :household_id, :households, :id So the people table has a foreign key into
2006 Apr 07
4
belongs_to and lookup tables
I have two classes, Listing and Warranty. A Listing (think of it as a product) may or may not have a Warranty from a lookup table. When I want the Warranty.company for a given Listing I want to say the following: @listing = Listing.find(4) @company = @listing.warranty.company In order to do that I did the following: class Listing < ActiveRecord::Base belongs_to :warranty end and
2006 Mar 13
3
validates_associated problem
Hello, I have a situation where an ''employee'' belongs to a ''department'' and have setup the relationship as follows. class Employee < ActiveRecord::Base belongs_to :department, :foregin_key => "department_id" validates_associated :department_id end class Department < ActiveRecord::Base has_many :employees def validate_on_update
2006 Jun 12
2
on_update current_timestamp in Migrations
Is there any way to set database columns to auto update a timestamp column on update? Can I do something like t.column "timestamp", :datetime, :default => :current_time, :null => false, :on_update => :current_timestamp or do i need to just use custom sql like sql = "ALTER TABLE `table` CHANGE `timestamp` `timestamp` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL
2006 Jul 13
6
Migrations + foreign keys
Hi all, In the AWDR author use the execute method to declare foreign keys: execute "alter table.... add constraint.... foreign key...." Is there a ruby sintax to declare a foreign key in a migration class? -- Posted via http://www.ruby-forum.com/.
2008 Feb 03
1
ActiveRecord object.valid? triggers unexepected results
I''m editing an ActiveRecord object in a session through AJAX, updating it with object.attributes = params[:object], and validating it with object.valid? Because it''s associated with other objects in a form, I want to save them all together. The surprise was that object.valid? triggers after_validation_on_update. I''m having an audit log and I was getting bogus entries.
2013 Mar 11
0
Any interest in various features from "schema_plus" gem?
Hello (I''m new to this group so please pardon any inappropriateness), I''m a primary maintainer of the schema_plus gem<https://github.com/lomba/schema_plus/>, which adds some capabilities to rails'' schema definitions. The gem has been around for several years and is pretty reliable. I''ve been wondering whether there''d be interest in folding