Changing main repo and database model modifications

43 views
Skip to first unread message

Jon Subscripted

unread,
Dec 7, 2020, 8:04:15 AM12/7/20
to web...@googlegroups.com
Hi all,
I want to change the main repo copy from which I work but when I do it I'm not longer capable of modifying the database. BTW the old and new repo are not in the same machine.

*My "sql.log" and every ".table" file are uploaded to the repo.
*The old repo has migrations enabled (both in db.py and table definitions).
*The new repo has migrations disabled and fake migrations enabled (both in db.py and table definitions).

I want to be able to change the DB from the new repo (in the new machine). How can I change my database changing repo? Which are the steps to follow?
Thanks, Jon.

Jon Subscripted

unread,
Dec 7, 2020, 10:10:06 AM12/7/20
to web...@googlegroups.com
Oh, I forgot to comment (and I believe it may be relevant) that I'm using a MySQL database.

And when I try to add a new column to a previously defined table (defined and created originally in another repo) I do get the error below:

InternalError: (1054, u"Unknown column 'tag.in_between' in 'field list'")
I'd really appreciate some guidance on this, as I'm going literally nuts with all the migration, frake migration, sql.log and tables business...
Thanks, Jon.

Jim S

unread,
Dec 7, 2020, 2:47:24 PM12/7/20
to web2py-users
Can you try setting migrate=True, fake_migrate=True and fake_migrate_all=True in the new repo?

either that, or copy the databases directory over from old repo to the new repo.

-Jim

Clemens

unread,
Dec 7, 2020, 2:54:18 PM12/7/20
to web2py-users
Please try not to use the .table files. You can just rename database folder to database.orig and create a new database folder in your application directory. This is necessary since on the "new machine" there are new databases created, I guess. Have a try. If it's solve the problem you can easily recover the old database directory with the original .table files.

Regards
Clemens

Jon Subscripted

unread,
Dec 8, 2020, 2:38:50 AM12/8/20
to web...@googlegroups.com
Thanks Clemens and Jim S.

So I guess that I should use the "python web2py.py -M -S <appname>" command option to create the new table files, right?

--
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 web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/43dc5ec9-2a60-4460-8911-ba00f8d699c5n%40googlegroups.com.

Jon Subscripted

unread,
Dec 8, 2020, 3:07:12 AM12/8/20
to web...@googlegroups.com
Hi Jim,
Just one question, what happens when you set migrate=True and fake_migrate=True at the same time?
Thanks, Jon.

--
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 web2py+un...@googlegroups.com.

Clemens

unread,
Dec 8, 2020, 3:22:28 AM12/8/20
to web2py-users
Hello Jon,

yes, this should do it. It's also fine to import an export of an existing DB. But you can just start your application, this should create the .table files at the first, I think.

Regards
Clemens

P.S.: Concerning migrate and fake_migrate options have a look there: http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#table_migrations
I usually just use migrate=True, if I'm working on the models on my development system. On production I use migrate=False and lazy_tables=True.

Jon Subscripted

unread,
Dec 8, 2020, 3:48:30 AM12/8/20
to web...@googlegroups.com
Hi Clemens,
Just some quick questions.

1) What happens with auth tables and python -S <appname> -M -P?  it does not seem to create the .table files
2) Regarding migration and fake migration. I tried to summarize my understanding in the table below (use a fixed width font to see it properly). How does web2py behave on the cases marked with '?' in the table below?
3) I also assume from what I read in the book that define_table migration flags override those from db.py DAL constructor call. Is this correct?

Thanks, Jon.
                        FAKE_MIGRATE
                     TRUE      FALSE
                +-----------+-------------+
                |           | changes     |
          TRUE  |     ?     | in DB &     |
                |           | .table files|
MIGRATE         +-------------------------+
          FALSE |NO changes |             |
                |in DB, just|     ?       |
                |in .table  |             |
                +-----------+-------------+


Jim S

unread,
Dec 8, 2020, 10:50:00 AM12/8/20
to web2py-users
I believe it will then perform the migration, but instead of running the migrations on the database, it will just update the files in /databases.

-Jim

Jon Subscripted

unread,
Dec 8, 2020, 12:50:36 PM12/8/20
to web...@googlegroups.com
Thanks Jim.

Libre de virus. www.avast.com


Libre de virus. www.avast.com

Jon Subscripted

unread,
Dec 8, 2020, 12:52:47 PM12/8/20
to web...@googlegroups.com
Sorry Clemens,
I hadn't checked your link correctly, it states it clearly with pseudo code how the flags work.
Thanks, Jon.

if DAL.migrate_enabled and table.migrate:
   if DAL.fake_migrate_all or table.fake_migrate:
       perform fake migration
   else:
       perform migration

Libre de virus. www.avast.com

Reply all
Reply to author
Forward
0 new messages