[cl-migrations-devel] first test ...
hello, i'm trying your cl-migrations tool. it seems very interesting ... i've some remarks : 1 - for cl-migrations' newbie (like me), it could be interesting to write in your example page (on cl.net) that we could change the *migration-dir* : CL-USER> (setf cl-migrations:*migration-dir* "/home/nicolas/tmp/") 2 - i try to creates the 1-.... file : CL-USER> (cl-migrations:generate "add-employees-table") junk in string "foo.lisp" [Condition of type SB-INT:SIMPLE-PARSE-ERROR] Restarts: 0: [ABORT] Return to SLIME's top level. 1: [ABORT] Exit debugger, returning to top level. Backtrace: 0: (PARSE-INTEGER "foo.lisp") 1: (CL-MIGRATIONS::GET-LATEST-MIGRATION) 2: (CL-MIGRATIONS:GENERATE "add-employees-table") 3: (SB-INT:SIMPLE-EVAL-IN-LEXENV (CL-MIGRATIONS:GENERATE "add-employees-table") #<NULL-LEXENV>) the error comes from that i've got a /home/nicolas/tmp/foo.lisp files and from this method (parse-integer) : (defun get-migration-number (file) (parse-integer (subseq (file-namestring file) 0 (search "-" (file-namestring file))))) i don't really how correct this ? throw an error ? return nil ? ... 3- try to creates the database model : CL-USER> (cl-migrations:generate "add-employees-table") "1-add-employees-table.lisp" CL-USER> (cl-migrations:migrate) WARNING: Exiting - .migrate.conf not found in the home directory A database error occurred: NIL / NIL NIL is not a database. [Condition of type CLSQL-SYS:SQL-DATABASE-ERROR] Restarts: 0: [ABORT] Return to SLIME's top level. 1: [ABORT] Exit debugger, returning to top level. Backtrace: 0: (CLSQL-SYS::SIGNAL-NO-DATABASE-ERROR NIL) 1: (CLSQL-SYS::SIGNAL-NO-DATABASE-ERROR NIL) 2: (CLSQL-SYS:SELECT CL-MIGRATIONS::VERSION :FROM "schema_info" :FLATP T :FIELD-NAMES NIL) 3: (CL-MIGRATIONS::GET-DB-VERSION) 4: (CL-MIGRATIONS:MIGRATE :VERSION NIL) 5: (SB-INT:SIMPLE-EVAL-IN-LEXENV (CL-MIGRATIONS:MIGRATE) #<NULL-LEXENV>) 6: (SWANK::EVAL-REGION "(cl-migrations:migrate) " T) i think i've got a problem with (read-specs) 4- creates the database model with default configuration CL-USER> (cl-migrations:generate "add-employees-table") Setting up migrations directory: "/home/nicolas/tmp/migrations/" The path #P"/home/nicolas/tmp/migrations/1-add-employees-table.lisp" does not exist. [Condition of type SB-INT:SIMPLE-FILE-ERROR] Restarts: 0: [ABORT] Return to SLIME's top level. 1: [ABORT] Exit debugger, returning to top level. i've got this on my .migrate.conf file : ((:mysql ("localhost" "test" "user" "user")) (:migration-dir ("/home/nicolas/tmp/migrations/"))) in the "generate" method, i think this could correct the problem : (ensure-directories-exist (directory-namestring #p"/home/nicolas/tmp/migrations/1-add-employees-table.lisp")) 5- Database model CL-USER> (ensure-directories-exist (directory-namestring #p"/home/nicolas/tmp/migrations/1-add-employees-table.lisp")) "/home/nicolas/tmp/migrations/" T CL-USER> (cl-migrations:generate "add-employees-table") "1-add-employees-table.lisp" CL-USER> (cl-migrations:migrate) Setting up migrations directory: "/home/nicolas/tmp/migrations/" ; loading system definition from ; /home/nicolas/.sbcl/systems/clsql-mysql.asd into #<PACKAGE "ASDF0"> ; registering #<SYSTEM :CLSQL-MYSQL {B6E3E39}> as CLSQL-MYSQL ; loading system definition from ; /home/nicolas/.sbcl/systems/clsql-uffi.asd into #<PACKAGE "ASDF0"> ; registering #<SYSTEM CLSQL-UFFI {BA36CB9}> as CLSQL-UFFI Schema table doesn't exist, creating. Database ready. Migration #1: EXEC: "create table employees (id serial, name varchar(100))" EXEC: "create table products (id serial, name varchar(100))" While accessing database #<MYSQL-DATABASE localhost/test/root OPEN {AA87289}> with expression "UPDATE SCHEMA_INFO SET VERSION = 1 WHERE (VERSION = 0)": Error 1146 / Table 'test.SCHEMA_INFO' doesn't exist has occurred. [Condition of type CLSQL-SYS:SQL-DATABASE-DATA-ERROR] Restarts: 0: [ABORT] Return to SLIME's top level. 1: [ABORT] Exit debugger, returning to top level. Backtrace: 0: ((SB-PCL::FAST-METHOD CLSQL-SYS:DATABASE-EXECUTE-COMMAND (T CLSQL-MYSQL:MYSQL-DATABASE)) #<unavailable argument> #<unavailable argument> "UPDATE SCHEMA_INFO SET VERSION = 1 WHERE (VERSION = 0)" #<CLSQL-MYSQL:MYSQL-DATABASE localhost/test/root OPEN {AA87289}>) 1: ((LAMBDA (SB-PCL::.PV-CELL. SB-PCL::.NEXT-METHOD-CALL. SB-PCL::.ARG0. SB-PCL::.ARG1.)) #<unavailable argument> #<unavailable argument> "UPDATE SCHEMA_INFO SET VERSION = 1 WHERE (VERSION = 0)" #<CLSQL-MYSQL:MYSQL-DATABASE localhost/test/root OPEN {AA87289}>) 2: ((SB-PCL::FAST-METHOD CLSQL-SYS:EXECUTE-COMMAND (STRING)) #<unused argument> #<unused argument> "UPDATE SCHEMA_INFO SET VERSION = 1 WHERE (VERSION = 0)" :DATABASE #<CLSQL-MYSQL:MYSQL-DATABASE localhost/test/root OPEN {AA87289}>) 3: ((SB-PCL::FAST-METHOD CLSQL-SYS:EXECUTE-COMMAND (CLSQL-SYS::%SQL-EXPRESSION)) #<unused argument> #<unused argument> #<CLSQL-SYS::SQL-UPDATE UPDATE SCHEMA_INFO SET VERSION = 1 WHERE (VERSION = 0)> :DATABASE #<CLSQL-MYSQL:MYSQL-DATABASE localhost/test/root OPEN {AA87289}>) in the database : mysql> show tables ; +----------------+ | Tables_in_test | +----------------+ | employees | | products | | schema_info | +----------------+ 3 rows in set (0.00 sec) mysql> desc products ; +-------+---------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+---------------------+------+-----+---------+----------------+ | id | bigint(20) unsigned | NO | PRI | NULL | auto_increment | | name | varchar(100) | YES | | NULL | | +-------+---------------------+------+-----+---------+----------------+ 2 rows in set (0.00 sec) mysql> desc employees ; +-------+---------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+---------------------+------+-----+---------+----------------+ | id | bigint(20) unsigned | NO | PRI | NULL | auto_increment | | name | varchar(100) | YES | | NULL | | +-------+---------------------+------+-----+---------+----------------+ 2 rows in set (0.00 sec) mysql> UPDATE SCHEMA_INFO SET VERSION = 1 WHERE (VERSION = 0); ERROR 1146 (42S02): Table 'test.SCHEMA_INFO' doesn't exist mysql> UPDATE schema_info SET VERSION = 1 WHERE (VERSION = 0); Query OK, 1 row affected (0.01 sec) Rows matched: 1 Changed: 1 Warnings: 0 with mysql the problem comes from the table name. i've got a question about this tool and the Ror equivalent : what about def-view-class ? in ror, you creates the SQL model and you generate objects wrapper ? in some project, i use def-view-class and i generate the SQL tables from theses objects ... i thinks it's a great tool ... i'll use it in some of my projects -- Nicolas Lamirault
Nicolas Lamirault wrote:
hello, i'm trying your cl-migrations tool. it seems very interesting ... i've some remarks :
Thank you. I'll try to address them one by one:
1 - for cl-migrations' newbie (like me), it could be interesting to write in your example page (on cl.net) that we could change the *migration-dir* :
CL-USER> (setf cl-migrations:*migration-dir* "/home/nicolas/tmp/")
I am not sure if this is a good idea - I exported that var so that people can print it out for checking - it gets set along with the database config, so the appropriate way to set this would be by creating the config file properly and then running the generate/migrate functions. I am thinking of not exporting this variable anymore, but I will see if there's a way decouple database spec from directory setting and handle this properly.
2 - i try to creates the 1-.... file :
CL-USER> (cl-migrations:generate "add-employees-table") junk in string "foo.lisp" [Condition of type SB-INT:SIMPLE-PARSE-ERROR]
Looks like you have a regular file in the directory - it's always good to create a separate directory just for migrations. This happens because cl-migrations reads all the files in the directory and sorts them according to their migration numbers in the filenames. Anyways, I will try to fix this so that regular files (without numbers) get ignored.
3- try to creates the database model :
CL-USER> (cl-migrations:generate "add-employees-table") "1-add-employees-table.lisp"
CL-USER> (cl-migrations:migrate) WARNING: Exiting - .migrate.conf not found in the home directory A database error occurred: NIL / NIL NIL is not a database. [Condition of type CLSQL-SYS:SQL-DATABASE-ERROR]
Most probably because you set the *migration-dir* directly and didn't create the .migrate.conf. Creating this file should fix the problem.
4- creates the database model with default configuration
CL-USER> (cl-migrations:generate "add-employees-table")
Setting up migrations directory: "/home/nicolas/tmp/migrations/"
The path #P"/home/nicolas/tmp/migrations/1-add-employees-table.lisp" does not exist. [Condition of type SB-INT:SIMPLE-FILE-ERROR]
in the "generate" method, i think this could correct the problem :
(ensure-directories-exist (directory-namestring #p"/home/nicolas/tmp/migrations/1-add-employees-table.lisp"))
Thanks, will patch this into the next release.
5- Database model
mysql> UPDATE SCHEMA_INFO SET VERSION = 1 WHERE (VERSION = 0); ERROR 1146 (42S02): Table 'test.SCHEMA_INFO' doesn't exist
mysql> UPDATE schema_info SET VERSION = 1 WHERE (VERSION = 0); Query OK, 1 row affected (0.01 sec) Rows matched: 1 Changed: 1 Warnings: 0
with mysql the problem comes from the table name.
Wow, I'm very surprised about this. Sorry, I mostly tested in PostgreSQL, so I missed this one. Isn't SQL supposed to be case-insensitive? Will fix this anyways.
i've got a question about this tool and the Ror equivalent : what about def-view-class ? in ror, you creates the SQL model and you generate objects wrapper ? in some project, i use def-view-class and i generate the SQL tables from theses objects ...
Hmm. Actually it's the other way round. There's a part of RoR called ActiveRecord that looks at the table (created by migrations or by hand with sql) and then automagically sets up the object and it's attributes (field names as slots). So, there's no need for something like def-view-class of CLSQL. Perhaps we need something like ActiveRecord in CL. But I think this behavior can be easily retrofitted to CLSQL or Postmodern.
i thinks it's a great tool ... i'll use it in some of my projects
Thanks a lot for the inputs. I will be a lot more careful about the bugs now. Little busy now, will push out a new version over the weekend. Best regards, Vamsee.
hello, Vamsee Kanakala <vamlists@gmail.com> writes:
Nicolas Lamirault wrote:
hello, i'm trying your cl-migrations tool. it seems very interesting ... i've some remarks :
Thank you. I'll try to address them one by one:
1 - for cl-migrations' newbie (like me), it could be interesting to write in your example page (on cl.net) that we could change the *migration-dir* :
CL-USER> (setf cl-migrations:*migration-dir* "/home/nicolas/tmp/")
I am not sure if this is a good idea - I exported that var so that people can print it out for checking - it gets set along with the database config, so the appropriate way to set this would be by creating the config file properly and then running the generate/migrate functions. I am thinking of not exporting this variable anymore, but I will see if there's a way decouple database spec from directory setting and handle this properly.
2 - i try to creates the 1-.... file :
CL-USER> (cl-migrations:generate "add-employees-table") junk in string "foo.lisp" [Condition of type SB-INT:SIMPLE-PARSE-ERROR]
Looks like you have a regular file in the directory - it's always good to create a separate directory just for migrations. This happens because cl-migrations reads all the files in the directory and sorts them according to their migration numbers in the filenames. Anyways, I will try to fix this so that regular files (without numbers) get ignored.
3- try to creates the database model :
CL-USER> (cl-migrations:generate "add-employees-table") "1-add-employees-table.lisp"
CL-USER> (cl-migrations:migrate) WARNING: Exiting - .migrate.conf not found in the home directory A database error occurred: NIL / NIL NIL is not a database. [Condition of type CLSQL-SYS:SQL-DATABASE-ERROR]
Most probably because you set the *migration-dir* directly and didn't create the .migrate.conf. Creating this file should fix the problem.
4- creates the database model with default configuration
CL-USER> (cl-migrations:generate "add-employees-table")
Setting up migrations directory: "/home/nicolas/tmp/migrations/"
The path #P"/home/nicolas/tmp/migrations/1-add-employees-table.lisp" does not exist. [Condition of type SB-INT:SIMPLE-FILE-ERROR]
in the "generate" method, i think this could correct the problem :
(ensure-directories-exist (directory-namestring #p"/home/nicolas/tmp/migrations/1-add-employees-table.lisp"))
Thanks, will patch this into the next release.
5- Database model
mysql> UPDATE SCHEMA_INFO SET VERSION = 1 WHERE (VERSION = 0); ERROR 1146 (42S02): Table 'test.SCHEMA_INFO' doesn't exist
mysql> UPDATE schema_info SET VERSION = 1 WHERE (VERSION = 0); Query OK, 1 row affected (0.01 sec) Rows matched: 1 Changed: 1 Warnings: 0
with mysql the problem comes from the table name.
Wow, I'm very surprised about this. Sorry, I mostly tested in PostgreSQL, so I missed this one. Isn't SQL supposed to be case-insensitive? Will fix this anyways.
i've got a question about this tool and the Ror equivalent : what about def-view-class ? in ror, you creates the SQL model and you generate objects wrapper ? in some project, i use def-view-class and i generate the SQL tables from theses objects ...
Hmm. Actually it's the other way round. There's a part of RoR called ActiveRecord that looks at the table (created by migrations or by hand with sql) and then automagically sets up the object and it's attributes (field names as slots). So, there's no need for something like def-view-class of CLSQL. Perhaps we need something like ActiveRecord in CL. But I think this behavior can be easily retrofitted to CLSQL or Postmodern.
i thinks it's a great tool ... i'll use it in some of my projects
Thanks a lot for the inputs. I will be a lot more careful about the bugs now. Little busy now, will push out a new version over the weekend.
great ! thanks for your reply ...
Best regards, Vamsee. _______________________________________________ cl-migrations-devel mailing list cl-migrations-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/cl-migrations-devel
-- Nicolas Lamirault
Nicolas Lamirault wrote:
5- Database model
[snip]
Migration #1: EXEC: "create table employees (id serial, name varchar(100))" EXEC: "create table products (id serial, name varchar(100))" While accessing database #<MYSQL-DATABASE localhost/test/root OPEN {AA87289}> with expression "UPDATE SCHEMA_INFO SET VERSION = 1 WHERE (VERSION = 0)": Error 1146 / Table 'test.SCHEMA_INFO' doesn't exist has occurred. [Condition of type CLSQL-SYS:SQL-DATABASE-DATA-ERROR]
It looks like a known problem. According to the clsql guys, it's better to solve this problem at the server side: http://lists.b9.com/pipermail/clsql-help/2004-December/000377.html The relevant mysql link: http://dev.mysql.com/doc/refman/5.0/en/identifier-case-sensitivity.html Hope this solves your problem. I have fixed the other problems you have reported - however, I am no longer exporting the *migration-dir*, to make sure the database connection is configured properly before the migrations are run. Decoupling *migration-dir* and database config is a little tricky now, will perhaps solve this in the next version. Thanks so much for the feedback. Regards, Vamsee
participants (2)
-
Nicolas Lamirault -
Vamsee Kanakala