petehamilton / citier

CITIER (Class Inheritance & Table Inheritance Embeddings for Rails) is a solution for simple Multiple Class Inheritance in Rails.
88 stars 24 forks source link

View_xxx does not exist | PostgreSQL #54

Closed kwent closed 12 years ago

kwent commented 12 years ago

Hi,

First, Thank you for this great tool !

I met the following problem when i try to seed my database :

citier -> Root Class
citier -> table_name -> triggers
citier -> Non Root Class
citier -> table_name -> soaps
citier -> tablename (view) -> view_soaps
rake aborted!
PG::Error: ERROR:  relation "view_soaps" does not exist
LINE 4:              WHERE a.attrelid = '"view_soaps"'::regclass
                                        ^
:             SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
              FROM pg_attribute a LEFT JOIN pg_attrdef d
                ON a.attrelid = d.adrelid AND a.attnum = d.adnum
             WHERE a.attrelid = '"view_soaps"'::regclass
               AND a.attnum > 0 AND NOT a.attisdropped
             ORDER BY a.attnum

Tasks: TOP => db:seed
(See full trace by running task with --trace)

My schema.rb file :

ActiveRecord::Schema.define(:version => 20120411115108) do

  create_table "soap", :force => true do |t|
    t.string   "wsdl_filename"
    t.datetime "created_at",    :null => false
    t.datetime "updated_at",    :null => false
  end

  create_table "triggers", :force => true do |t|
    t.string   "type", :null => false
    t.string   "name"
    t.string   "description"
    t.string   "host"
    t.integer  "port"
    t.integer  "timeout",     :default => 60
    t.datetime "created_at",                  :null => false
    t.datetime "updated_at",                  :null => false
  end

end

My migration file :

class CreateSoaps < ActiveRecord::Migration
  def self.up
    create_table :soaps do |t|
      t.string :wsdl_filename
      t.timestamps
    end
    create_citier_view(Soap)
  end

  def self.down
    drop_citier_view(Soap)
    drop_table :soaps
  end
end

My environment configuration :

About your application's environment
Ruby version              1.8.7 (x86_64-linux)
RubyGems version          1.3.7
Rack version              1.4
Rails version             3.2.3
JavaScript Runtime        therubyracer (V8)
Active Record version     3.2.3
Action Pack version       3.2.3
Active Resource version   3.2.3
Action Mailer version     3.2.3
Active Support version    3.2.3
Middleware                ActionDispatch::Static, Rack::Lock, #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x7f173b6ffaa0>, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::DebugExceptions, ActionDispatch::RemoteIp, ActionDispatch::Reloader, ActionDispatch::Callbacks, ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, ActionDispatch::Flash, ActionDispatch::ParamsParser, ActionDispatch::Head, Rack::ConditionalGet, Rack::ETag, ActionDispatch::BestStandardsSupport
Application root          /var/www/html/Komets
Environment               development
Database adapter          postgresql

Could you help me to fix this problem ?

Notes : All models are well write as your documentation.

Best Regards,

vjnunez commented 12 years ago

Any news on this subject? Im having the same issue with my app:

Mysql2::Error: Table 'invoicer_development.view_invoices' doesn't exist: SHOW FULL FIELDS FROM view_invoices

when i do create_citier_view(Invoice) in my migrations.

Any ideas? I already have 'rails_sql_views' included in my gemfile.

kwent commented 12 years ago

Hello,

It was because rake tried to down table the migration before re up table. So he tries to delete invoicer_development.view_invoices but this view is none existant.

2 solutions.

Regards,