MLstate / opalang

The Opa Language for Web Application Development
http://opalang.org
Other
1.24k stars 125 forks source link

[fix] Postgres errors on app startup: use alternate DDL statements to avoid #163

Closed twopoint718 closed 9 years ago

twopoint718 commented 9 years ago

I'm getting Postgres error messages each time I start my compiled app:

$ ./biking.exe
Http serving on http://tha-tha.local:8080
DbPostgres(biking) An error occurs while processing an initial query:
error: {postgres = {error = [{f1 = 83; f2 = ERROR}, {f1 = 67; f2 = 42710}, {f1 = 77; f2 = language "plpgsql" already exists}, {f1 = 70; f2 = proclang.c}, {f1 = 76; f2 = 356}, {f1 = 82; f2 = create_proc_lang}]}}
query: CREATE LANGUAGE plpgsql

DbPostgres(biking) An error occurs while processing an initial query:
error: {postgres = {error = [{f1 = 83; f2 = ERROR}, {f1 = 67; f2 = 42P07}, {f1 = 77; f2 = relation "_default" already exists}, {f1 = 70; f2 = heap.c}, {f1 = 76; f2 = 1047}, {f1 = 82; f2 = heap_create_with_catalog}]}}
query: CREATE TABLE _default(counter INT8, _id INT8,  PRIMARY KEY(_id))

Using CREATE TABLE IF NOT EXISTS and CREATE OR REPLACE LANGUAGE will fix these in Postgres versions 9.1 and greater (released in 2011).