Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rake db:seed error #4

Open
gosuri opened this issue Oct 11, 2011 · 4 comments
Open

rake db:seed error #4

gosuri opened this issue Oct 11, 2011 · 4 comments

Comments

@gosuri
Copy link
Collaborator

gosuri commented Oct 11, 2011

PGError: ERROR: relation "schema_migrations" does not exist
LINE 4: WHERE a.attrelid = '"schema_migrations"'::regcl...
^
: 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 = '"schema_migrations"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum

Tasks: TOP => db:seed => db:abort_if_pending_migrations

@dcleven
Copy link
Collaborator

dcleven commented Oct 12, 2011

When you run db:seed rake uses ActiveRecord to check for pending_migrations. Which queries the public.schema_migrations table, which doesn't exist in public, it is in global.

@dcleven
Copy link
Collaborator

dcleven commented Oct 12, 2011

Is this a viable solution?

In config/application.rb
config.active_record.table_name_prefix = 'global'

@gosuri
Copy link
Collaborator Author

gosuri commented Dec 6, 2012

HI filo,

Apologies. I accidentally deleted your question on github. It should be okay to add to existing applications.

Greg Osuri
Twitter (http://twitter.com/GregOsuri) • Blog (http://gregosuri.com?tracking=sig)
Mobile: +1 (415) 683 1097 • Skype: greg.osuri

On Wednesday, October 12, 2011 at 10:54 AM, Doug Cleven wrote:

Is this a viable solution?

In config/application.rb
config.active_record.table_name_prefix = 'global'

Reply to this email directly or view it on GitHub:
#4 (comment)

@filo47
Copy link

filo47 commented Dec 6, 2012

Greg,

Thank you so much for getting back to me. I recently
converted my rails app to mutlitenancy following the code in a recent
railscast
(http://railscasts.com/episodes/389-multitenancy-with-postgresql). I
wanted to try your solution to see how they compare.

My question is,
HOW DO YOU RE-CREATE TABLES IN NEW SCHEMAS FOR MODELS THAT PREVIOUSLY
EXIST? Running a shared migration does nothing because my migrations
have already been run. Running the tenant migration only adds a tenant
schema not the needed tables?

Thank you for the help,

Phil Hemmers

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

No branches or pull requests

3 participants