search for: drop_table

Displaying 20 results from an estimated 146 matches for "drop_table".

2006 Jun 13
11
Question: Migration - multiple creates
...? I''m guessing that each new create script requires a seperate class so formatted this way. Perhaps I''m wrong. TIA Stuart class CreateTable1 < ActiveRecord::Migration def self.up create_table :table1s do |t| t.column :length, :string end end def self.down drop_table :table1s end end class CreateTable2 < ActiveRecord::Migration def self.up create_table :table2s do |t| t.column :length, :string end end def self.down drop_table :table2s end end class CreateTable3 < ActiveRecord::Migration def self.up create_table :table3s do...
2006 Mar 31
2
A.R. Associations problem
...opic, :string t.column :author_id, :integer t.column :created_on, :datetime end create_table :posts do |t| t.column :post, :text t.column :topic_id, :integer t.column :author_id, :integer t.column :created_on, :datetime end end def self.down drop_table :authors drop_table :topics drop_table :posts end end Here are the model associations: class Author < ActiveRecord::Base has_many :topics has_many :posts end class Topic < ActiveRecord::Base has_many :posts belongs_to :author end -- Posted via http://www.ruby-forum.com/.
2006 May 25
5
rake migrate VERSION=0 doesn''t appear to execute
...oke db:schema:dump (first_time) ** Invoke environment ** Execute db:schema:dump ** Execute migrate but my tables aren''t dropped. Here''s my migration: class CreateInitialSchema < ActiveRecord::Migration def self.up ...creates a bunch of tables end def self.down drop_table :target_lists drop_table :jobs drop_table :stylesheets drop_table :images drop_table :documents end end Does rake migrate VERSION=0 rollback the very FIRST migration? What am I doing wrong? Thanks, Wes -- Posted via http://www.ruby-forum.com/.
2006 Feb 19
3
multi-sql problem?
hi all, how to excute multi sql statement in rails #------------------------------------------------------- sql_1 = ''drop table if exists test'' sql_2 = ''create temporary table test select * from test_1'' sql_3=''select * from test'' #------------------------------------------------------- any ideas all regards -- Posted via
2008 Feb 19
1
[CruiseControl] RubyOnRails build 8896 failed
...:151:in `log'' ./test/cases/../../lib/active_record/connection_adapters/postgresql_adapter.rb:407:in `execute_without_counting'' ./test/cases/helper.rb:46:in `execute'' ./test/cases/../../lib/active_record/connection_adapters/abstract/schema_statements.rb:116:in `drop_table'' ./test/cases/associations/eager_load_nested_include_test.rb:45:in `drop_tables'' ./test/cases/associations/eager_load_nested_include_test.rb:43:in `each'' ./test/cases/associations/eager_load_nested_include_test.rb:43:in `drop_tables'' ./test/cases/...
2006 Feb 15
2
migrations still
I think I am pissing into the wind to make migrations work at this point. Looking at http://wiki.rubyonrails.org/rails/pages/UnderstandingMigrations it appears that the problem that I am having is that postgresql can''t do the drop_table part because of the foreign_key keys (constraints) which requires ''cascade'' as an option to drop some of the tables that have other tables which include a column from the table I am attempting to drop which would leave things in a mess. I thought I would ask anyway... Am I suppo...
2008 Oct 26
3
Undefined method f_title
...ription => ''Use this template to create a blank form.'') end def self.up create_table :sample_forms do |t| t.string :name, :null => false t.string :f_title t.text :description t.timestamps end self.add_data end def self.down drop_table :sample_forms end end While migrating, it gives the error ''undefined method f_title=''. I first thought ''title'' was reserved so I renamed it to ''f_title''. When I remove it, the process starts over with the description attribute. CmdJohnson -...
2006 Mar 29
2
Rake Migrations for Rails 1.1
...quot;, :string t.column "address", :string t.column "city", :string t.column "state", :string t.column "zipcode", :string t.column "pay_type", :decimal t.column "fulfilled_at", :datetime end end def self.down drop_table :pages drop_table :users drop_table :line_items drop_table :orders end end Any clues? -- Posted via http://www.ruby-forum.com/.
2006 Apr 07
4
How to generate mapping with migration
...otes_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, :null=>false end end def self.down drop_table :categories_notes end end Now, I''d like to define both fields as primary key, but after I read the API documentation, I''ll wonder how I could pass to parameters to the :primary parameter of create_table. Any hints appreciated, -- Daniel V?lkerts Protected by Anti Pesto. -...
2006 Mar 15
3
Self-referential join model does not work
...t.column :node_id, :integer, :null => false t.column :related_node_id, :integer, :null => false t.column :label, :string, :null => false, :default => '''' end add_index :edges, [:node_id, :related_node_id], :unique => true end def self.down drop_table :edges drop_table :nodes end end The two models are as follows: class Node < ActiveRecord::Base validates_presence_of :title has_many :edges, :dependent => true has_many :related_nodes, :through => :edges, :class_name => ''Node'', :foreign_key => '...
2006 Jun 21
1
Migration with foreign key won''t work
...description, :string, :limit => 20 end # Foreign Keys add_foreign_key_constraint :artists, :artist_type_id, :artist_types, :artist_type, :on_update => :cascade, :on_delete => :restrict # artists(artist_type_id) references artist_types(artist_type) end def self.down drop_table :artists drop_table :artist_types # Foreign Keys remove_foreign_key_constraint :artists, :foreign_key => :artist_type_id end end When running it, everything goes well up to the foreign keys. I get the following error: -- add_foreign_key_constraint(:artists, :artist_type_id, :a...
2009 Nov 04
0
The error occurred while evaluating nil.prefetch_primary_key
...f self.up create_table :connections do |t| t.string :name # Name t.string :alias # Alias-Name t.string :descr # Description t.timestamps end end def self.down drop_table :connections end end class CreateProjects < ActiveRecord::Migration def self.up create_table :projects do |t| t.string :name # Name t.string :descr # Description t.timestamps end end def self.down dro...
2006 Apr 23
2
Rails Recipes
...t.column :email, :string t.column :phone, :string t.column :address_line1, :string t.column :address_line2, :string t.column :city, :string t.column :state, :string t.column :country, :string t.column :postal_code, :string end end def self.down drop_table :contacts end end -- Posted via http://www.ruby-forum.com/.
2010 Jun 29
3
belongs_to. Association methods don't pass data to DB
...ion of the issue: GIVEN: # migration class CreateArticlesAndAuthorsTables < ActiveRecord::Migration   def self.up     create_table :articles do |t|       t.text     :title       t.integer :author_id     end     create_table :authors do |t|       t.text :name     end   end   def self.down     drop_table :articles     drop_table :authors   end end # articles model class Article < ActiveRecord::Base   belongs_to :author end # authors model class Author < ActiverRecord::Base   has_many :articles end WHEN: >> Article.create(:title => ''one'').author = Author.create(:...
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..
2006 Jan 21
5
Help...why ''rake migrate'' can''t be executed on RadRails
...:time end create_table :items do |t| t.column :list_id, :integer t.column :note, :string t.column :completion, :boolean, :default => false t.column :position, :integer t.column :created_on, :time t.column :updated_on, :time end end def self.down drop_table :lists drop_table :items end end =================================== ------------------------------------------------------------- Kouta Osabe E-mail:kota0919wasabi@yahoo.co.jp Always Look on the Bright Side of Life! - from Monty Python ------------------------------------------...
2006 Jul 10
3
Problem with migrations
...ees < ActiveRecord::Migration def self.up create_table :employees do |t| t.column :employee_number, :integer t.column :name, :string t.column :location, :string t.column :department, :integer t.column :company_code, :string end end def self.down drop_table :employees end end 002 class AddEmployeeData < ActiveRecord::Migration def self.up Employee.create( :employee_number => ''1234'', :name => ''Bob B'', :location => ''Office'', :department => '...
2011 Mar 22
2
Problems with SQLite3
Hi! I''ve got a very strange problem. Suddenly the SQLite3 Backend stopped working. Example 1: > rake db:rollback == CreateProducts: reverting ================================================= -- drop_table(:products) rake aborted! An error has occurred, this and all later migrations canceled: SQLite3::SQLException: near "CASCADE": syntax error: DROP TABLE "products" CASCADE I googled for this error message, but didn''t find anything useful. BTW, there is nothing special...
2006 Aug 17
0
super-newb needs help with has_many and other things...
...Migration def self.up create_table :topics do |t| t.column :name, :string, :null => false t.column :description, :string t.column :creator, :string, :null => false t.column :creationdate, :timestamp, :null => false end end def self.down drop_table :topics end end 002: class CreateArticles < ActiveRecord::Migration def self.up create_table :articles do |t| t.column :name, :string, :null => false t.column :description, :string t.column :body, :text, :null => false t.column :creator, :string, :null...
2008 Apr 30
4
Beginner mysql problem
....column "name", :string t.column "address", :string t.column "city", :string t.column "state", :string t.column "zipcode", :string end end def self.down drop_table :people end end and the error is: == ContactDb: migrating ======================================================= -- create_table("people") rake aborted! Mysql::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right sy...