On 2015-01-12, 3:31 PM, "OC" wrote:
Tim, On 12. 1. 2015, at 23:59, Timothy Worman <li...@thetimmy.com<mailto:li...@thetimmy.com>> wrote: I don’t know how far you’ve dug - but just in case I’ll throw this out. One of the keys to how all this works is ERXSQLHelper sqlHelper = ERXSQLHelper.newSQLHelper. This returns the vendor specific ERXSQLHelper for your database (Frontbase). DB specific code is there. Where do I set this up for the ERXMigration* stuff? There does not seem to be any place for me to set this up. ERXSQLHelper was the first place I have looked, but I haven't found there anything related to adding (and removing/renaming) columns, only stuff related to whole entities/tables. Perhaps I did look wrong. Just my 2¢, but instead of that large block of code, why not just change some properties, run migrations at app startup, and declare your changes there? Migrations work and you don’t have to reinvent the wheel. Then, if your SQL continues to be incorrect, you know where to focus. Can you please point me to some howto? To be frank, I have absolutely no idea what “migration” is. (Truth is, I must be missing something pretty obvious at the documentation side: whilst I can find my way in WOnder if I know what exactly to search for, so far, I haven't found anything which would help me to find a support for some general functionality, unless 'find wonderdoc | xargs fgrep thedesiredthing' helps, which it very often does not. Consider my current case -- I need to sync tables to model /more details below/, and perhaps I'm just dumb, but "migration" is about the very last word I would search for, to fulfill that need?!? I don't migrate anything to anywhere; all I need is to synchronize the database to the model.) *cough* JavaDoc https://github.com/wocommunity/wonder/blob/master/Frameworks/Core/ERExtensions/Sources/er/extensions/migration/package.html Anyway, my workflow is this (a) I open the database and read from there some dynamic information (works OK) (b) based on this information, I add a number of dynamic EOAttributes to my model (works OK too) (c) at this moment, I need to sync the DB and model, namely - adding columns to the database for EOAttributes which do not have any - removing colums from the database for which there are no EOAttributes - removing and re-adding columns for which there are EOAttributes of an incompatible kind If the migration thing can do this, it would be just great. Migrations is only intended to run at a very early place in app startup. Chuck Thanks a big lot, OC On Jan 12, 2015, at 2:18 PM, OC <o...@ocs.cz<mailto:o...@ocs.cz>> wrote: P.S. my current environment is Groovy 2.3.8 / WebObjects 5.4.3 / ERExtensions 6.1.2-SNAPSHOT / Java 1.7.0_13 / Mac OS X 10.8.5 / FrontBase 7.2 On 12. 1. 2015, at 22:56, OC <o...@ocs.cz<mailto:o...@ocs.cz>> wrote: Theodore, On 12. 1. 2015, at 19:00, Theodore Petrosky <tedp...@yahoo.com<mailto:tedp...@yahoo.com>> wrote: have you looked at the migrations? ERXMigrationTable personTable = database.existingTableNamed("person"); personTable.existingColumnNamed("Foo").renameTo("Bar”); personTable.newStringColumn(name, width, allowsNull) well... the API looks OK, but in practice it does not seem quite work. Can you (or anybody knowledgeable) please point out what am I doing wrong? Here's my code (sans error checking etc. for better readability) === EOObjectStoreCoordinator osc=EOObjectStoreCoordinator.defaultCoordinator() EODatabaseContext ctxt=ERXEOAccessUtilities.databaseContextForEntityNamed(osc,'DBAuction') ctxt.lock(); try { EOAdaptorChannel ach = ctxt.availableChannel().adaptorChannel(); if (!ach.isOpen()) ach.openChannel(); def tables=ach.describeTableNames() // looks like Migration API does not read the current state reliably EOModel dbModel=ach.describeModelWithTableNames(tables) ERXMigrationDatabase mdb=nil // created on-demand mdg.models.each { EOModel localModel -> localModel.entities.each { EOEntity localEntity -> if (localEntity.isAbstractEntity()) return String tname=localEntity.externalName() EOEntity dbEntity=dbModel.entityNamed(tname) ERXMigrationTable mtable=nil // on-demand localEntity.attributes.each { EOAttribute localAttribute -> String cname=localAttribute.columnName() EOAttribute dbAttribute=dbEntity.attributeNamed(cname) if (!dbAttribute) { println " adding column $cname ($localAttribute.name): $localAttribute.externalType (VT: $localAttribute.valueType) ..." if (!mdb) mdb=ERXMigrationDatabase.database(ach) if (!mtable) mtable=mdb.existingTableNamed(tname) switch (localAttribute.externalType) { ... case 'TIMESTAMP': mtable.newTimestampColumn(cname,YES) break } println " - OK" } } } } } finally { ctxt.unlock() } === but it crashes, printing out === adding column DC_ID (ID): TIMESTAMP (VT: null) ... 22:42:09.409 INFO Executing alter table T_AUCTION null DC_ID TIMESTAMP //log:er.extensions.jdbc.ERXJDBCUtilities [main] ... Caused by: java.lang.RuntimeException: Failed to execute 'alter table T_AUCTION null DC_ID TIMESTAMP'. Caused by: java.sql.SQLException: Syntax error 179. Illegal ALTER TABLE statement. === Well self-evidently it _is_ an illegal statement, it lacks "add column" having "null" instead; but what's the culprit and how to fix the problem? (Note: I've tried to bump up log levels to log4j.logger.er.extensions.jdbc.ERXJDBCUtilities=TRACE log4j.logger.er.extensions.migration.ERXMigrationDatabase=TRACE log4j.logger.er.extensions.migration.ERXMigrationTable=TRACE log4j.logger.er.extensions.migration.ERXMigrationColumn=TRACE but no more logs occurred anyway.) Thanks, OC _______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com<mailto:Webobjects-dev@lists.apple.com>) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/ocs%40ocs.cz This email sent to o...@ocs.cz<mailto:o...@ocs.cz> _______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com<mailto:Webobjects-dev@lists.apple.com>) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/lists%40thetimmy.com This email sent to li...@thetimmy.com<mailto:li...@thetimmy.com> _______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com<mailto:Webobjects-dev@lists.apple.com>) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/chill%40gevityinc.com This email sent to ch...@gevityinc.com<mailto:ch...@gevityinc.com>
_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com