Continuing the discussion from In Uplink, is it safe to reset anvil.tables.AppTables.cache between connections? Is there a better way?:
What I’m trying to do:
My App has DevTest data, in its Default Database, accessible from a couple of Environments. I want to copy some “bootstrap” data from that database to its other database named Public, accessible from an environment named Published.
The “bootstrap” data defines the database’s first, “prototype” user, including attached records that define default values for all new users. It has to be there. Without it, the post-login app-startup sequence will crash.
What I’ve tried and what’s not working:
-
I’ve successfully created database Public, as a clone of the Default Database. All tables were created empty.
Table Members was set, in the Default Database, as the users table, ages ago. As you can see, its clone is set to be read-writable from Server-side code.
-
I’ve told Environment Published that it is to use database Public:
So it should be using Public’s table Members instead. -
This is brand-new code, writing many records, starting with the root of this hierarchy, the new (1st) user, so it’s likely to fail somewhere along the line, leaving partial results in the database. Thus, in case I’ve already succeeded in creating that user, I query table Members. This naturally returns
None
. Public.Members is empty. Then, to create this first user, I have a call toanvil.users.signup_with_email()
.
It is at this specific point that I get the dreaded message,
This table cannot be written or searched by this app
Code Sample:
new_user = anvil.users.signup_with_email(email_address, password)
It’s as if Environment Published is trying to use the wrong table.
Is there some setting that I’m missing?
Edit (2022-11-23): This may be a clue: All 3 of my anvil.yaml
files have
server_config: {user_table: 61863}
(I have one file each, for the branches used by Development, Testing, and Published.)
This suggests that anvil.users
is, indeed, sharing the same Members table among all of the Environments.
What do I have to do to get Published to use its own Members table?