similar to: ActiveRecord Migrations, without autonumbered PK''s

Displaying 20 results from an estimated 4000 matches similar to: "ActiveRecord Migrations, without autonumbered PK''s"

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
2009 Oct 08
6
Eager Loading a Relationship That Has No PK/FK
I''m attempting to wrestle an old DB into Rails. This relationship is giving me trouble: class Show < AR::Base has_many :segments end class Segment < AR::Base belongs_to :show has_one :media #this has no PK/FK relation end A Segment is "linked" to Media by Media.name, which is the result of concatenating Segment.name and Segment.part. As I said there are is no
2005 Jun 16
3
PostgreSQL Scaffold Doesn't Insert PK?
I am new to Rails and Ruby. I''ve been a WebObjects developer for a few years and before that J2EE (shudder). I wanted to try RoR so I am porting an existing Web app. I am running the latest release on Tiger and PG8. Right now my single table has three attributes: id | integer | not null hotel_name | character varying(255) | not null hotel_location |
2007 Aug 30
1
belongs_to with foreign keys that reference non primary key columns
Hello, I have a situation where the foreign key into a table doesn''t correspond to that table''s primary key: my_table ------------- id (pk) name ... other_table -------------- id (pk) my_table_name (fk references my_table(name)) ... I want to be able to say something like: class OtherTable < ActiveRecord::Base belongs_to :my_table, :foreign_key => { :my_table_name
2006 Apr 18
6
Postgresql and ActiveRecords problems
Hi all. I have a problem with postgresql PK columns and ActiveRecord. The error is: PGError: ERROR: null value in column "item_id" violates not-null. Ok, it''s wrong to insert NULL into PK columns, but rails doing it. How to fix? So sad..
2010 Aug 19
1
Composite primary keys and :joins=>
I have a legacy db with the following simplified structure: Table-A: type_key, code_key, name, ... # PKs are type_key and code_key, there is no id col and I cannot alter this db Table-B: # each row has only the code as a foreign_key, the type_key is hard-coded to "FOOKEY" an_id, code, ... Models: class TableB < AR::Base set_table_name ''table_b''
2006 Apr 07
4
How to generate mapping with migration
Hi there, I''ve tried to add a m:n mapping table using the migration mechanism. ruby script\generate migration add_categories_notes_mapping and filled the migration file with: class AddNotesCategoriesMapping < ActiveRecord::Migration def self.up create_table :categories_notes do |t| t.column :category_id, :integer, :null=>false t.column :note_id, :integer,
2006 Jun 12
2
Migrations and primary id
I set up a migration yesterday for the first time and remembered that Rails will assign a primary id column on it''s own. No need to put it in to the SQL. The name of the column though is just "id", is there a way to over ride the default if I wanted ? TIA Stuart -------------- next part -------------- An HTML attachment was scrubbed... URL:
2006 Apr 07
2
has_one not using the pk?
Hello, im trying to wrap a fairly ugly legacy schema using AR. How to handle normalized informations which aren''t connected via the pk? create table what ( myid int, myclass int, ;; references blahclass.blahid mygender int ) create table blahclass ( blahid int, mdesc1 text, fdesc1 text) ) I would like to wrap this as class What < AR::Base has_one :blahclass class
2006 Mar 12
5
AR - Migrations - how to use a varchar as primary key instead of int ?
Hi I''d like to have a varchar primary key named id instead of the default int id. Does anyone knows how to specify this from migrations ? Should I also specify something in the model class ? thanks! Thibaut -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060312/797bca4b/attachment.html
2005 Dec 17
4
Rake migrate and creating join tables
Just wondering if there''s a way to use migrations to generate join tables (where the table columns comprise only of foreign keys to other tables, and where the primary key is all the foreign keys taken together). I made the changes manually in MySQL, then did rake db_schema_dump and it gave something like this: create_table "apples_oranges", :id => false, :force
2006 Aug 04
3
Migration::alter statements ??
Hi, Where to put the execute statements in migration scripts? e.g, I would like to create a table and add a foreign_key reference. def self.up ?? execute "alter table ...." create_table :my_table do |t| t.column :user, :string end ?? execute "alter table ...." end Should the execute statement be above the table creation or below the table creation? Logically I
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
2007 Nov 12
7
schema_info always wants to be 3, even when set to 7
Hi all, I''m having a very odd problem with db:migrate. I''m using Rails 1.2.5 on Windows XP SP2 and Ruby 1.8.6 I have seven migrations. If I run them with an empty database, it runs the first three, then halts. When I look in schema_info, the version is 3. If I run db:migrate VERSION=7, then it runs through the remaining 4 migrations, and the version is 7 in the DB.
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
2013 Oct 25
6
Migrate postgresql database to uuid
Hi all, I am using rails 3.1 and ruby 1.9.3,Now i want to use uuid concept in rails 3 for existing data so i did like :- create_table :posts, :id => false do |t| t.string :uuid, :limit => 36, :primary => true end ActiveRecord::Base.class_eval do # old rails versions set_primary_key ''uuid'' before_create :generate_uuid def generate_uuid self.id =
2006 Apr 24
4
[TIP] Ensure your test data is valid
Recently I wanted to check that my test data was valid. Seems like a reasonable thing to want to do so I thought I''d share the rake task. Add this code to a rake file in lib/tasks and run with rake db:fixtures:validate. It will print out the class, record id and error messages for any model objects that fail validation. Enjoy! -Jonathan. -- namespace :db do namespace :fixtures do
2008 Mar 28
0
Vacancy Principal Postdoc PK-PD modeling The Netherlands
________________________________ Principal Post-Doctoral Fellow PKPD modelling platform (full time) Leiden University, Leiden, The Netherlands <javascript:doredirect();> Job description ________________________________ TOP Institute Pharma (TI Pharma) has granted our proposal to set up a mechanism-based PK-PD modelling platform. This platform focuses on the transfer of
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
2016 Feb 04
0
CEBA-2016:0112 CentOS 6 cups-pk-helper FASTTRACK BugFix Update
CentOS Errata and Bugfix Advisory 2016:0112 Upstream details at : https://rhn.redhat.com/errata/RHBA-2016-0112.html The following updated files have been uploaded and are currently syncing to the mirrors: ( sha256sum Filename ) i386: 67aaac8ee7bce20c58ecccae6ef50b97bc6e43b94abe0fb74d24d48cac255520 cups-pk-helper-0.0.4-13.el6.i686.rpm x86_64: