Roundup Tracker - Issues

Message7906

Author rouilj
Recipients ivanov, rouilj
Date 2023-12-19.22:25:14
Message-id <20231219222511.3615B6A01F3@pe15.cs.umb.edu>
In-reply-to <cb4a90b06053dbc6cd9bd49bc7141a08@riseup.net>
Hi Ivanov:

In message <cb4a90b06053dbc6cd9bd49bc7141a08@riseup.net>,
Ivanov writes:
>>>My postgresql user is the owner of the selected database, but does not
>>>have permission to create databases. 
>>>
>>>I think the problem is here, but I don't want to give them additional
>>>permissions just to initially populate the database.
>>>
>>>Maybe some kind of non-destructive initialization might be possible,
>>>without recreating the entire database?
>> 
>> It's supposed IIRC. It checks to see if the db exists. If the db
>> exists it tries to load the roundup schema. If that fails it
>> initializes the db. But it doesn't look like you are getting that far.
>
>It seems that I did not describe this problem quite accurately above.
>
>Currently, when I run the 'roundup-admin initialise' command, Roundup
>always prompts to recreate the database if it already exists. This
>happens either way: when the database is just created, or when I run the
>'roundup-admin migrate' command to add tables before performing
>initialization.

You don't need to migrate if you haven't run initialization. When the
db is initialized it makes the same tables that migrate does (assuming
no bugs). Indeed currently running init after migrate drops the db
that migrate populated and recreates all the tables.

I understand your use case better now. You are not running initialize
multiple times on a tracker. You have an existing db (that is empty,
no tables or anything else).

What happens if you do this:

  start with an installed and configured (in config.ini) tracker and
  an empty database (as above).

  run 'roundup-admin -i tracker-home list user' 

I think this should create all the tables but not create any rows in
the tables.

The list command should show nothing.

'init' runs initial_data.py. initial_data.py includes commands to
populate the tables (users, status, ...).

I'm not sure if you can use roundup-admin to create the admin and
anonymous users manually (because the admin user in the db isn't
defined). However you can use psql to set the admin id=1,
username=admin and roles=Admin. Then once that is present for the
admin user, you can set the admin password using roundup-admin, create
the anonymous user etc.

I would have to check but I think a change to create an:

  init --nocreatedb

that just loads initial_data.py would be relatively
easy. Alternatively we can add a 'pragma nocreatedb=true'. (We can
create a new ticket for this).

That would bypass the prompt and nuke() calls. It's nuke that actually
destroys/creates a new db. (BTW the prompt can already be bypassed by
using 'pragma force=true' IIRC.)

>It doesn't look like the command is trying to load the data before
>asking to recreate the database. I looked at the admin.py code and it
>seems like this is indeed the case.

You're correct. The exists test in admin.py calls db_connect which
just does a database connect. No check of the schema table happens
until the tracker's open.

>But it seems that using separate commands to create admin and anonymous
>and then creating priorities/statuses/etc using the web interface is
>easier than using initialization if I don't want to grant the CREATEDB
>privilege to the postgresql role.

The user and other data is installed by running initial_data.py during
init. Trackers can be written to use specific items in the db. For
example the classic template statusauditor.py needs the chatting status.
Without it it won't operate correctly. So correctly creating these
entries could be tricky.

The minimal template only defines the two required users: admin,
anonymous. No other data.

If the test above with 'list user' works as I expect, than yes you can
skip init and manually populate the user table then use the web
interface.
History
Date User Action Args
2023-12-19 22:25:15rouiljsetrecipients: + rouilj, ivanov
2023-12-19 22:25:15rouiljlinkissue2551299 messages
2023-12-19 22:25:14rouiljcreate