on dev help sign in
fix some more test errors
7cf2cc8Eitan Chatav
squeal-postgresql/src/Squeal/PostgreSQL.hs+3−2
@@ -37,8 +37,9 @@ type UsersColumns =
37 , "name" ::: 'NoDef :=> 'NotNull 'PGtext ]
37 , "name" ::: 'NoDef :=> 'NotNull 'PGtext ]
38type UsersConstraints = '[ "pk_users" ::: 'PrimaryKey '["id"] ]
38type UsersConstraints = '[ "pk_users" ::: 'PrimaryKey '["id"] ]
39type EmailsColumns =
39type EmailsColumns =
40− '[ "pk_emails" ::: 'PrimaryKey '["id"]
40+ '[ "id" ::: 'Def :=> 'NotNull 'PGint4
41− , "fk_user_id" ::: 'ForeignKey '["user_id"] "users" '["id"] ]
41+ , "user_id" ::: 'NoDef :=> 'NotNull 'PGint4
42+ , "email" ::: 'NoDef :=> 'Null 'PGtext ]
42type EmailsConstraints =
43type EmailsConstraints =
43 '[ "pk_emails" ::: 'PrimaryKey '["id"]
44 '[ "pk_emails" ::: 'PrimaryKey '["id"]
44 , "fk_user_id" ::: 'ForeignKey '["user_id"] "users" '["id"] ]
45 , "fk_user_id" ::: 'ForeignKey '["user_id"] "users" '["id"] ]
squeal-postgresql/src/Squeal/PostgreSQL/Definition.hs+11−10
@@ -153,7 +153,7 @@ type Table = '[] :=>
153
153
154>>> :{
154>>> :{
155let
155let
156− setup :: Definition '[] '["tab" ::: 'Table Table]
156+ setup :: Definition '["public" ::: '[]] '["public" ::: '["tab" ::: 'Table Table]]
157 setup = createTable #tab
157 setup = createTable #tab
158 (nullable int `as` #a :* nullable real `as` #b) Nil
158 (nullable int `as` #a :* nullable real `as` #b) Nil
159in printSQL setup
159in printSQL setup
@@ -189,11 +189,11 @@ type Table = '[] :=>
189 , "b" ::: 'NoDef :=> 'Null 'PGfloat4 ]
189 , "b" ::: 'NoDef :=> 'Null 'PGfloat4 ]
190:}
190:}
191
191
192−>>> type Schema = '["tab" ::: 'Table Table]
192+>>> type DB = '["public" ::: '["tab" ::: 'Table Table]]
193
193
194>>> :{
194>>> :{
195let
195let
196− setup :: Definition Schema Schema
196+ setup :: Definition DB DB
197 setup = createTableIfNotExists #tab
197 setup = createTableIfNotExists #tab
198 (nullable int `as` #a :* nullable real `as` #b) Nil
198 (nullable int `as` #a :* nullable real `as` #b) Nil
199in printSQL setup
199in printSQL setup
@@ -280,7 +280,7 @@ type Schema = '[
280
280
281>>> :{
281>>> :{
282let
282let
283− definition :: Definition '[] Schema
283+ definition :: Definition '["public" ::: '[]] '["public" ::: Schema]
284 definition = createTable #tab
284 definition = createTable #tab
285 ( (int & notNullable) `as` #a :*
285 ( (int & notNullable) `as` #a :*
286 (int & notNullable) `as` #b )
286 (int & notNullable) `as` #b )
@@ -315,7 +315,7 @@ type Schema = '[
315
315
316>>> :{
316>>> :{
317let
317let
318− definition :: Definition '[] Schema
318+ definition :: Definition '["public" ::: '[]] '["public" ::: Schema]
319 definition = createTable #tab
319 definition = createTable #tab
320 ( (int & nullable) `as` #a :*
320 ( (int & nullable) `as` #a :*
321 (int & nullable) `as` #b )
321 (int & nullable) `as` #b )
@@ -345,11 +345,12 @@ type Schema = '[
345 "id" ::: 'Def :=> 'NotNull 'PGint4,
345 "id" ::: 'Def :=> 'NotNull 'PGint4,
346 "name" ::: 'NoDef :=> 'NotNull 'PGtext
346 "name" ::: 'NoDef :=> 'NotNull 'PGtext
347 ])]
347 ])]
348+type DB = '["public" ::: Schema]
348:}
349:}
349
350
350>>> :{
351>>> :{
351let
352let
352− definition :: Definition '[] Schema
353+ definition :: Definition '["public" ::: '[]] DB
353 definition = createTable #tab
354 definition = createTable #tab
354 ( serial `as` #id :*
355 ( serial `as` #id :*
355 (text & notNullable) `as` #name )
356 (text & notNullable) `as` #name )
@@ -395,7 +396,7 @@ type Schema =
395
396
396>>> :{
397>>> :{
397let
398let
398− setup :: Definition '[] Schema
399+ setup :: Definition '["public" ::: '[]] '["public" ::: Schema]
399 setup =
400 setup =
400 createTable #users
401 createTable #users
401 ( serial `as` #id :*
402 ( serial `as` #id :*
@@ -430,7 +431,7 @@ type Schema =
430
431
431>>> :{
432>>> :{
432let
433let
433− setup :: Definition '[] Schema
434+ setup :: Definition '["public" ::: '[]] '["public" ::: Schema]
434 setup =
435 setup =
435 createTable #employees
436 createTable #employees
436 ( serial `as` #id :*
437 ( serial `as` #id :*
@@ -533,7 +534,7 @@ DROP statements
533--
534--
534-- >>> :{
535-- >>> :{
535-- let
536-- let
536−-- definition :: Definition '["muh_table" ::: 'Table t] '[]
537+-- definition :: Definition '["public" ::: '["muh_table" ::: 'Table t]] '["public" ::: '[]]
537-- definition = dropTable #muh_table
538-- definition = dropTable #muh_table
538-- :}
539-- :}
539--
540--
@@ -591,7 +592,7 @@ newtype AlterTable
591-- let
592-- let
592-- definition :: Definition
593-- definition :: Definition
593-- '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]]
594-- '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]]
594−-- '["public" ::: '["tab" ::: 'Table ('["positive" ::: Check '["col"]] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]]
595+-- '["public" ::: '["tab" ::: 'Table ('["positive" ::: 'Check '["col"]] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]]
595-- definition = alterTable #tab (addConstraint #positive (check #col (#col .> 0)))
596-- definition = alterTable #tab (addConstraint #positive (check #col (#col .> 0)))
596-- in printSQL definition
597-- in printSQL definition
597-- :}
598-- :}
squeal-postgresql/src/Squeal/PostgreSQL/Migration.hs+6−6
@@ -31,7 +31,7 @@ type EmailsTable =
31
31
32>>> :{
32>>> :{
33let
33let
34− makeUsers :: Migration IO '[] '["users" ::: 'Table UsersTable]
34+ makeUsers :: Migration IO '["public" ::: '[]] '["public" ::: '["users" ::: 'Table UsersTable]]
35 makeUsers = Migration
35 makeUsers = Migration
36 { name = "make users table"
36 { name = "make users table"
37 , up = void . define $
37 , up = void . define $
@@ -45,8 +45,8 @@ let
45
45
46>>> :{
46>>> :{
47let
47let
48− makeEmails :: Migration IO '["users" ::: 'Table UsersTable]
48+ makeEmails :: Migration IO '["public" ::: '["users" ::: 'Table UsersTable]]
49− '["users" ::: 'Table UsersTable, "emails" ::: 'Table EmailsTable]
49+ '["public" ::: '["users" ::: 'Table UsersTable, "emails" ::: 'Table EmailsTable]]
50 makeEmails = Migration
50 makeEmails = Migration
51 { name = "make emails table"
51 { name = "make emails table"
52 , up = void . define $
52 , up = void . define $
@@ -68,10 +68,10 @@ Now that we have a couple migrations we can chain them together.
68>>> :{
68>>> :{
69let
69let
70 numMigrations
70 numMigrations
71− :: Has "schema_migrations" schema ('Table MigrationsTable)
71+ :: Has "migrations" db MigrationsSchema
72− => PQ schema schema IO ()
72+ => PQ db db IO ()
73 numMigrations = do
73 numMigrations = do
74− result <- runQuery (selectStar (from (table (#schema_migrations `as` #m))))
74+ result <- runQuery (selectStar (from (table (#migrations ! #schema_migrations `as` #m))))
75 num <- ntuples result
75 num <- ntuples result
76 liftBase $ print num
76 liftBase $ print num
77:}
77:}