Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

[PATCH] Create schema during 'rake db:create' from schema_search_path if it does not exist for PostgreSQL

#1605

Setting a non-existent schema name for the schema_search_path will cause errors when trying to migrate:


PGError: ERROR:  schema "products" does not exist
: SET search_path TO products, public

http://github.com/saturnflyer/ra... (UPDATED commit) adds methods to the postgresql_adapter:

  • create_schema(name, username) (creating the schema for the given user)
  • all_schemas (returning an array of schema names)
  • has_schema?(name) (returns boolean based on the existence of the given schema)

With this patch, the message "Schema products has been created." will be output when the schema is first created.

Reported by Jim Gay · December 20th, 2008 @ 05:47 AM

State: stale
Milestone: 3.0.2
Assigned to: nobody
Importance: Medium

Activity

  1. Jim Gay
    Jim Gay

    Didn't realize where the tests needed to go. I'm working on them now... sorry for the early noise

    December 20th, 2008 @ 07:28 PM

  2. Jim Gay
    Jim Gay
    • Assigned user set to Tarmo Tänav

    Updated code with tests

    December 21st, 2008 @ 04:51 AM

  3. Pratik
    Pratik
    • State changed from new to incomplete

    Could you please upload a patch using git-format-patch ? http://guides.rails.info/contrib... should help.

    Thanks !

    March 8th, 2009 @ 02:38 PM

  4. Jim Gay
    Jim Gay

    Lighthouse is not saving my message when I add the patch file.

    March 8th, 2009 @ 05:58 PM

  5. Jim Gay
  6. Pratik
    Pratik
    • State changed from incomplete to open

    March 9th, 2009 @ 10:00 AM

  7. Rizwan Reza
    Rizwan Reza
    • State changed from open to verified
    • Tag changed from 2.3, adapters, databases.rake, patch, postgresql, rake to 3.0, adapters, databases.rake, patch, postgresql, rake
    • Assigned user changed from Tarmo Tänav to Pratik
    • Title changed from Create schema during 'rake db:create' from schema_search_path if it does not exist for PostgreSQL to [PATCH] Create schema during 'rake db:create' from schema_search_path if it does not exist for PostgreSQL
    • Milestone cleared.

    This is exactly the same patch but applies cleanly on master.

    March 26th, 2010 @ 01:46 PM

  8. Rizwan Reza
  9. eagle.anton (at gmail)
    eagle.anton (at gmail)
    • Assigned user changed from Pratik to Rizwan Reza

    This commit breaks test database prepare by rake db:test:prepare.
    Because query:

    SELECT schema_name FROM information_schema.schemata;
    

    doesn't return any schema for non SUPERUSER and it tries to create it.
    And how result we have error:

    PGError: ERROR:  permission denied for database postgres
    : CREATE SCHEMA "public" AUTHORIZATION "user"
    

    and not created test db.

    April 1st, 2010 @ 11:10 AM

  10. Rizwan Reza
    Rizwan Reza

    Don't you need to have authorization for 'postgres' database to create schemas?

    April 5th, 2010 @ 03:47 PM

  11. eagle.anton (at gmail)
    eagle.anton (at gmail)

    Ok. Let's talk about workflow with postgres.

    There are my steps:

    sudo -u postgres psql
    CREATE ROLE user_name with createdb login password 'pass';
    
    There is i don't want to grant superuser privileges to user. User is having permissions to create db only now. In that way new db will be created in public schema which for all users same time. Should i give him authorization to create 'public' schema in 'postgres' db? I think no. Am i right?

    April 6th, 2010 @ 12:37 PM

  12. Michael Koziarski
    Michael Koziarski
    • State changed from resolved to open

    eagle.anton is right, this breaks my ability to run tests,

    the cure is worse than the disease here.

    Also, why's it trying to create the public schema anyway?

    April 9th, 2010 @ 12:14 AM

  13. Dan Pickett
    Dan Pickett
    • Tag changed from 3.0, adapters, databases.rake, patch, postgresql, rake to 3.0, adapters, bugmash, databases.rake, patch, postgresql, rake

    May 15th, 2010 @ 01:53 AM

  14. Rizwan Reza
    Rizwan Reza
    • State changed from open to stale
    • Assigned user cleared.

    June 8th, 2010 @ 04:39 PM

  15. Jeremy Kemper
    Jeremy Kemper
    • Milestone set to 3.0.2
    • Importance changed from to Medium

    October 15th, 2010 @ 11:01 PM