db won't recreate when create site from scratch

63 views
Skip to first unread message

b.l. masters

unread,
Dec 22, 2016, 12:57:52 PM12/22/16
to web2py-users
Hi

I am attempting to recreate my web2py app, from a clean install on an amazon instance with an standard install of web2py plus a git clone of an existing web2py application. My git repo ignores the database directory. Also, I am not using git to control the entire web2py application/I do not use the web2py git plugin (for a variety of reasons). So my git repo is just of my web2py application's folder, that I clone inside of the existing larger web2py applications folder.

However, when I install a new version of Web2py on an amazon instance, and then clone my application folder into the web2py application, the databases are not being recreated.

I've seen a few related issues that others have experienced. Since no database folder has been created at all in my case, deleting existing tables isn't relevant to my particular instance. And I have already added the following to my model file, as the recommended way of dealing with problematic migrations:


db.define_table(...., migrate=True, fake_migrate=True)
db = DAL(..., fake_migrate_all=True)


I have also tried many, many multiple combinations of the migration settings, to see if I could get something to work: migrate, fake_migrate, migrate_enabled, fake_migrate_enabled.

Regardless of what I try,  the databases are not being created, and I get the following:


Internal error

Ticket issued: unrecoverable


I am just using the standard Sqlite database that is created by Web2py. And the admin and welcome sites that are automatically created at install are working just fine.

Any help would be appreciated, as I have a need to rebuild this site clean, and I would also like to be confident that I could readily rebuild a web2py app from my git repo, when needed.



Dave S

unread,
Dec 22, 2016, 4:19:04 PM12/22/16
to web2py-users
First question ... does .../web2py/applications/ myapp/databases (a directory) exist?

/dps

b.l.masters

unread,
Dec 22, 2016, 4:24:13 PM12/22/16
to web...@googlegroups.com
No. The directory doesn't exist at all. Since I include that directory
in my git ignore file, when I clone my application there is no databases
folder.
> <https://54.191.223.145/admin/default/ticket/unrecoverable>
>
>
> I am just using the standard Sqlite database that is created by
> Web2py. And the admin and welcome sites that are automatically
> created at install are working just fine.
>
> Any help would be appreciated, as I have a need to rebuild this site
> clean, and I would also like to be confident that I could readily
> rebuild a web2py app from my git repo, when needed.
>
>
> First question ... does .../web2py/applications/ myapp/databases (a
> directory) exist?
>
> /dps
>
> --
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/e3SYa5D6HB0/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+un...@googlegroups.com
> <mailto:web2py+un...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

Dave S

unread,
Dec 22, 2016, 4:46:23 PM12/22/16
to web2py-users


On Thursday, December 22, 2016 at 1:24:13 PM UTC-8, b.l. masters wrote:
No. The directory doesn't exist at all. Since I include that directory
in my git ignore file, when I clone my application there is no databases
folder.


Try using mkdir.

/dps
 

b.l.masters

unread,
Dec 22, 2016, 5:01:39 PM12/22/16
to web...@googlegroups.com
Yeah. I already tried that. It doesn't do anything.

Dave S

unread,
Dec 22, 2016, 5:20:45 PM12/22/16
to web2py-users


On Thursday, December 22, 2016 at 2:01:39 PM UTC-8, b.l. masters wrote:
Yeah. I already tried that. It doesn't do anything.


Well, the next suggestion I have is to be sure that other required directories exist.  Anything in the first level of the welcome and example apps is a good place to start. (private may be superfluous)

/dps

b.l. masters

unread,
Dec 22, 2016, 5:42:05 PM12/22/16
to web...@googlegroups.com
Basically I ignore any directories that I don't want to "share" between my local, my test and my production. I do not have the following:

databases
errors
uploads
sessions
private

So, I went ahead and mkdir each of these and did an apache restart.  Still the same error.

Thanks for your help so far. I've spent a fair amount of time now trying to figure this one out, and its becoming frustrating.

To unsubscribe from this group and all its topics, send an email to web2py+unsubscribe@googlegroups.com.

b.l. masters

unread,
Dec 22, 2016, 6:14:20 PM12/22/16
to web...@googlegroups.com
Ok. Actually that was something. I realized that I gave the directories the wrong permissions when I created these. So I went ahead and reassigned to www-data and now I am getting the following:

Validation error, field:username <gluon.validators.IS_NOT_IN_DB object at 0x7f1d49dcd2d0>

It has now created databases. Or at least there are database files showing in the databases directory. However, when I attempt to create a user, this is the traceback message from the Database administration view:

    Traceback (most recent call last):
  File "/home/www-data/web2py/applications/[myappsname]/controllers/appadmin.py", line 249, in select
    nrows = db(query, ignore_common_filters=True).count()
  File "/home/www-data/web2py/gluon/packages/dal/pydal/objects.py", line 2010, in count
    return db._adapter.count(self.query, distinct)
  File "/home/www-data/web2py/gluon/packages/dal/pydal/adapters/base.py", line 1321, in count
    self.execute(self._count(query, distinct))
  File "/home/www-data/web2py/gluon/packages/dal/pydal/adapters/base.py", line 1388, in execute
    return self.log_execute(*a, **b)
  File "/home/www-data/web2py/gluon/packages/dal/pydal/adapters/base.py", line 1382, in log_execute
    ret = self.get_cursor().execute(command, *a[1:], **b)
OperationalError: no such table: auth_user


But this feels like progress. :-)

These are my current settings migration settings:

db = DAL(..., migrate=True, fake_migrate_all=True)

db.define_table(..., migrate=True, fake_migrate=True

auth.define_tables(username=True, signature=False, migrate=True)

Thanks again for any help.



Dave S

unread,
Dec 23, 2016, 5:23:28 PM12/23/16
to web2py-users


On Thursday, December 22, 2016 at 3:14:20 PM UTC-8, b.l. masters wrote:
Ok. Actually that was something. I realized that I gave the directories the wrong permissions when I created these. So I went ahead and reassigned to www-data and now I am getting the following:

Validation error, field:username <gluon.validators.IS_NOT_IN_DB object at 0x7f1d49dcd2d0>

It has now created databases. Or at least there are database files showing in the databases directory. However, when I attempt to create a user, this is the traceback message from the Database administration view:

    Traceback (most recent call last):
[...] 
  File "/home/www-data/web2py/gluon/packages/dal/pydal/adapters/base.py", line 1382, in log_execute
    ret = self.get_cursor().execute(command, *a[1:], **b)
OperationalError: no such table: auth_user


But this feels like progress. :-)

These are my current settings migration settings:

db = DAL(..., migrate=True, fake_migrate_all=True)

db.define_table(..., migrate=True, fake_migrate=True

auth.define_tables(username=True, signature=False, migrate=True)

Thanks again for any help.


Do you  instantiate Auth in your db.py?

/dps

b.l. masters

unread,
Jan 4, 2017, 12:39:31 PM1/4/17
to web...@googlegroups.com
Hi

Thanks for getting back. I got sidetracked with holiday travels and some other work.

Here is what finally worked. I made sure that my databases folder was completed empty (not just the .table files). I switched everything to:

db = DAL(... migrate_enabled=False, migrate=False)

db.define_table(
    auth.settings.table_user_name,... migrate=False)

auth.define_tables(username=True, signature=False, migrate=False)


And then I switched it to:

db = DAL(... migrate_enabled=True)

db.define_table(
    auth.settings.table_user_name,... migrate=True)

auth.define_tables(username=True, signature=False, migrate=True)


Using the combination of these two settings in that order and making sure the databases folder was completely empty seemed to be the fix...


Reply all
Reply to author
Forward
0 new messages