Skip to content
This repository has been archived by the owner on Mar 10, 2018. It is now read-only.

ERROR: relation "coupons_models_coupons" does not exist #18

Open
jessesanford opened this issue Apr 6, 2016 · 3 comments
Open

ERROR: relation "coupons_models_coupons" does not exist #18

jessesanford opened this issue Apr 6, 2016 · 3 comments

Comments

@jessesanford
Copy link

Followed installation instructions as best as I could. I imagine there might be an generate coupons:install step that I am missing? Nothing in the readme about it. Anyone else getting this?

PG::UndefinedTable: ERROR: relation "coupons_models_coupons" does not exist LINE 5: WHERE a.attrelid = '"coupons_models_coupons"'... ^ : SELECT a.attname, format_type(a.atttypid, a.atttypmod), pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod FROM pg_attribute a LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum WHERE a.attrelid = '"coupons_models_coupons"'::regclass AND a.attnum > 0 AND NOT a.attisdropped ORDER BY a.attnum

@cabgfx
Copy link
Contributor

cabgfx commented Apr 7, 2016

Yes, you'll need to run the rake task coupons:install:migrations.

From bundle exec rake -T:

rake coupons:install:migrations         # Copy migrations from coupons to application

This will copy over the migration template. Running this migration creates the two tables you need: coupons and coupon_redemptions.

It's missing from the install guide.

For reference, here's my schema.rb:

  create_table "coupon_redemptions", force: :cascade do |t|
    t.integer  "coupon_id",  null: false
    t.string   "user_id"
    t.string   "order_id"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end

  create_table "coupons", force: :cascade do |t|
    t.string   "code",                                    null: false
    t.string   "description"
    t.date     "valid_from",                              null: false
    t.date     "valid_until"
    t.integer  "redemption_limit",         default: 1,    null: false
    t.integer  "coupon_redemptions_count", default: 0,    null: false
    t.integer  "amount",                   default: 0,    null: false
    t.string   "type",                                    null: false
    t.datetime "created_at",                              null: false
    t.datetime "updated_at",                              null: false
    t.text     "attachments",              default: "{}", null: false
  end

I have had this gem running merrily in production for about 5-6 months, so you should be able to achieve the same 👍

@LuisHCK
Copy link

LuisHCK commented May 31, 2016

luishck@HP-14:~/projects/liveapp$ rake coupons:install
rake aborted!
Don't know how to build task 'coupons:install' (see --tasks)
/home/luishck/.rvm/gems/ruby-2.2.4/bin/ruby_executable_hooks:15:in `eval'
/home/luishck/.rvm/gems/ruby-2.2.4/bin/ruby_executable_hooks:15:in `<main>'
(See full trace by running task with --trace)
luishck@HP-14:~/projects/liveapp$ 

luishck@HP-14:~/projects/liveapp$ rails g coupons:install
Running via Spring preloader in process 8170
Could not find generator 'coupons:install'. Maybe you meant 'responders:install', 'survey:install' or 'devise:install'
Run `rails generate --help` for more options.

... And yes, the gem is already in my gemfile

@cabgfx
Copy link
Contributor

cabgfx commented Jun 2, 2016

@LuisHCK You need to run rake coupons:install:migrations — note the last part; :migrations.
This is the only rake task included with the gem (ie. there is no coupons:install)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants