Note that there are some explanatory texts on larger screens.

plurals
  1. POGrails with PostgreSQL not generating tables
    primarykey
    data
    text
    <p>So I have some simple domain classes that I have ensured are not using any PostgreSQL (or any other vendor, for that matter) reserved words. Executing <code>grails schema-export</code> produces a ddl which when run against the same database will successfully execute, and create all tables without issue. </p> <p>However, when running my grails application, I get the error <code>ERROR: relation "artist" does not exist</code>. (artist being the domain I am trying to create a sample of in BootStrap.groovy).</p> <p>Looking at my database, I can see that none of the tables have been created for my domains. </p> <p>I have enabled all logging for <code>org.hibernate</code>, but there is nothing there that would indicate any problem. The only issue I can see is that there is no logging that relates to the creation of any tables, only what appears to be sample queries for simple selects.</p> <p>Here is my DataSource.groovy:</p> <pre><code>dataSource { pooled = true driverClassName = "org.postgresql.Driver" dialect = "org.hibernate.dialect.PostgreSQLDialect" username = "my_username" password = "my_password" } hibernate { cache.use_second_level_cache = false cache.use_query_cache = false cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory' } // environment specific settings environments { development { dataSource { dbcreate = "create-drop" url = "jdbc:postgresql://localhost:5432/dev" } } test { dataSource { dbCreate = "update" url = "jdbc:postgresql://localhost:5432/test" } } production { dataSource { dbCreate = "update" url = "jdbc:postgresql://localhost:5432/prod" pooled = true properties { maxActive = -1 minEvictableIdleTimeMillis=1800000 timeBetweenEvictionRunsMillis=1800000 numTestsPerEvictionRun=3 testOnBorrow=true testWhileIdle=true testOnReturn=true validationQuery="SELECT 1" } } } } </code></pre> <p>I have verified that the credentials (fakes above) are valid, the user has permissions, database is running at the specified location, etc. </p> <p>Is there anything that I am missing, or any other type of logging that I can enable that will perhaps show what the error is, or aid in finding it?</p> <p>What I find most curious is that the ddl generated by <code>schema-export</code> runs just fine. Does grails generate the SQL differently at runtime, or is there anything that would cause grails not to execute any of the create statements?</p> <p>Grails version 2.1.1, PostgreSQL 9.2.1</p> <p>BootStrap as requested:</p> <pre><code>import my.site.domain.artist.* class BootStrap { def init = { servletContext -&gt; System.out.println("\n") log.info("---------------------------------------------------") log.info("BootStrap initializing...") log.info("---------------------------------------------------") TimeZone.setDefault(TimeZone.getTimeZone("UTC")) log.info("Default TimeZone set to " + TimeZone.getDefault().displayName) Artist artist = new Artist(artistName: 'Artist Name', shortBio: "Short Bio", biography: "Bio", url: "/some_artist") artist.save() if(artist.hasErrors()) { log.info(artist.errors) } else { log.info("--Artist--") log.info("dateCreated: " + artist.dateCreated) log.info("lastUpdated: " + artist.lastUpdated) log.info("mediumImageURL: " + artist.mediumImageURL) } } def destroy = { } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload