Hi Massimo

I have created standalone functions that reorders table fields and support 
for indexing regular fields by adding "indexed" to the Field signature at 
objects.py
Before trying the script please add indexed=False to the Field signature 
and self.indexed = indexed in objects.py, or overwrite with the attached 
objects.py file.

Its naive and in progress as it only supports common mysql types.

Please let me know how it looks, ill try to integrate this into pydal on my 
own but i still have to study how.

Thanks
Best Regards.



On Wednesday, 24 January 2018 at 00:01:33 UTC Alfonso Serra wrote:

> This works only on newly created fields over MySQL. Moving fields around 
> on your model wont reorder them. 
>
> Version 2.15.3-stable+timestamp.2017.08.07.12.51.45
> migrator.py line 364
>                     field_position = sql_fields[key]['sortable']
>                     after = "FIRST"
>                     if field_position > 1:
>                         for f in sql_fields:
>                             if sql_fields[f]['sortable'] == 
> field_position - 1:
>                                 after = "AFTER `%s`" % f
>                                 break
>                     query = ['ALTER TABLE %s ADD %s %s %s;' % (
>                         table._rname, sql_fields[key]['rname'],
>                         sql_fields_aux[key]['sql'].replace(', ', new_add), 
> after)]
>
> Theres no way to implement column reorder because the db is not being 
> asked for the table schema, this information is read from the migration 
> files. This function only checks whther the fields on your model are in the 
> migration files, in no particular order. It would be nice if there were a 
> way.
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/44824305-8c1b-4aac-858f-668e5e065cacn%40googlegroups.com.

<<attachment: db_functions.zip>>

Reply via email to