Recess Developer Forums: Request: Update and Delete Models - Recess Developer Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Request: Update and Delete Models Would be great to be able to Edit models with Recess Tools!

#1 User is offline   TigerMunky Icon

  • Group: Members
  • Posts: 9
  • Joined: 01-October 09
  • LocationJozi, South Africa

Posted 01 October 2009 - 09:03 PM

Would be great to be able to Edit and Delete models with Recess Tools!

It actually would be even more cool if there were a way to save and restore "model preferences"...

e.g.


Tiger's Models List v1 (TMLv1.rml ~ Recess Modeling Language?)

-> Model=user
-> Table
-> isExists=true
-> dataSource=Default
-> table=users
-> Table Properties
-> id
-> pk=true
-> type=integer(AutoIncrement)
-> username
-> pk=false
-> type=string
...
TM

"It's only work if somebody makes you do it"
0

#2 User is offline   Rafał Filipek Icon

  • Group: Members
  • Posts: 35
  • Joined: 28-August 09
  • LocationPoland

Posted 04 October 2009 - 05:44 PM

It looks like Rails migrations for me :) I like Rails migrations, but we use them in console. Now there is no such a thing in Recess. I don't see any advantages of adding migrations to Recess Tools. How to call them from shell or other script ? If you want to remove column all You have to do is remove it from model and table ( or You can even delete unused columns form database later ).

In fact it would be much better if there won't be full list of columns of table. I think we have this list, because is faster than generate them from 'DESCRIBE [tablename]' query.
Yes, in Poland we have a internet connection ;]
0

#3 User is offline   KrisJordan Icon

  • Administrator
  • Icon
  • Group: Administrators
  • Posts: 78
  • Joined: 25-August 09
  • LocationNorth Carolina, USA

Posted 05 October 2009 - 01:23 PM

This is a longer term goal and should be possible (though, could break dependent code!). The biggest road block, currently, is a proper way of doing operations like these on SQLite databases. Their 'alter table' last I checked was nowhere near as pleasant as MySQL's. Does anyone have experience writing scripts that manipulate already created tables in SQlite?
0

#4 User is offline   TigerMunky Icon

  • Group: Members
  • Posts: 9
  • Joined: 01-October 09
  • LocationJozi, South Africa

Posted 05 October 2009 - 01:30 PM

View PostKrisJordan, on 05 October 2009 - 08:23 PM, said:

This is a longer term goal and should be possible (though, could break dependent code!). The biggest road block, currently, is a proper way of doing operations like these on SQLite databases. Their 'alter table' last I checked was nowhere near as pleasant as MySQL's. Does anyone have experience writing scripts that manipulate already created tables in SQlite?



Ah see, I guess a temp work around for that then could be something like:

  • Backup table data
  • Remove table
  • Create table with or without new columns
  • Restore the data of the columns that were not deleted

TM

"It's only work if somebody makes you do it"
0

#5 User is offline   KrisJordan Icon

  • Administrator
  • Icon
  • Group: Administrators
  • Posts: 78
  • Joined: 25-August 09
  • LocationNorth Carolina, USA

Posted 05 October 2009 - 01:49 PM

@TigerMunky - yes, I believe that is probably how it will have to be done. Any interest in prototyping the code for this?
0

#6 User is offline   TigerMunky Icon

  • Group: Members
  • Posts: 9
  • Joined: 01-October 09
  • LocationJozi, South Africa

Posted 05 October 2009 - 01:54 PM

View PostKrisJordan, on 05 October 2009 - 08:49 PM, said:

@TigerMunky - yes, I believe that is probably how it will have to be done. Any interest in prototyping the code for this?


I am on tight schedules but am willing to make an attempt during some spare time...

How do I get started?
TM

"It's only work if somebody makes you do it"
0

#7 User is offline   Rafał Filipek Icon

  • Group: Members
  • Posts: 35
  • Joined: 28-August 09
  • LocationPoland

Posted 05 October 2009 - 08:36 PM

View PostKrisJordan, on 05 October 2009 - 08:23 PM, said:

This is a longer term goal and should be possible (though, could break dependent code!). The biggest road block, currently, is a proper way of doing operations like these on SQLite databases. Their 'alter table' last I checked was nowhere near as pleasant as MySQL's. Does anyone have experience writing scripts that manipulate already created tables in SQlite?

In fact alter table is not possible in sqlite. all you c do is to for example create temp table, like:
BEGIN TRANSACTION;
CREATE TEMPORARY TABLE Bar(a,B);
INSERT INTO Bar SELECT a,b FROM Foo;
DROP TABLE Foo;
CREATE TABLE Foo(a,B);
INSERT INTO Foo SELECT a,b FROM Bar;
DROP TABLE Bar;
COMMIT;

it sucks but imo there wont be anything much better :/
Yes, in Poland we have a internet connection ;]
1

#8 User is offline   KrisJordan Icon

  • Administrator
  • Icon
  • Group: Administrators
  • Posts: 78
  • Joined: 25-August 09
  • LocationNorth Carolina, USA

Posted 06 October 2009 - 12:53 PM

Very helpful Rafal.

When you do an INSERT INTO filled by a SELECT is it just the order of the columns that matter or are you trying to match column names, too?

Scenarios we have:

* Add a column
* Remove a column
* Rename a column
* Retype a column (I realize SQLite doesn't care too much about column type other than integer autoincrement but Recess uses type info from sqlite as semantic sugar)

Rafal's snippet shows renaming a column. Rafal could you mock up the other scenarios, too?

This is looking less challenging than I originally thought, just need to create a wrapper around these operations.
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users