#11333 closed enhancement (fixed)
TracAdmin command for DB schema
Reported by: | Owned by: | Ryan J Ollos | |
---|---|---|---|
Priority: | normal | Milestone: | 1.2 |
Component: | admin/console | Version: | 1.0.1 |
Severity: | normal | Keywords: | schema initenv |
Cc: | ethan.jucovy@… | Branch: | |
Release Notes: |
The TracAdmin |
||
API Changes: | |||
Internal Changes: |
Description (last modified by )
Offer a trac-admin command to generate DB schema (and maybe add a minimal set of rows to system
table ?) . This could be useful to regenerate the database from scratch by invoking a subsequent upgrade
while still keeping the rest of the environment intact . See trac-users thread for discussion .
Attachments (0)
Change History (17)
comment:1 by , 11 years ago
Cc: | added |
---|
comment:2 by , 11 years ago
comment:3 by , 11 years ago
Patches are ready . See patches available at URLs mentioned above
$ /srv/venv/python/trac/trac-mq/bin/python trac/admin/tests/console.py ............................................................................................................... ---------------------------------------------------------------------- Ran 111 tests in 8.246s OK
comment:4 by , 11 years ago
These are the results after adding one more test case to check that DB config is preserved on failure and invoking DatabaseManager.shutdown
as suggested by Ethan Jucovy via trac-dev@…
$ python trac/admin/tests/console.py ................................................................................................................ ---------------------------------------------------------------------- Ran 112 tests in 7.436s OK
comment:5 by , 11 years ago
Hello,
That was a fast patch ! I tested by modifying my trac.ini database string and the database is correctly initialized with your new trac-admin command. I havent' understood why you removed the wiki load_pages, but I suppose that you had good reasons (we just have to remember loading default wiki pages after creating the database).
Thanks !
comment:6 by , 11 years ago
Cc: | added |
---|
follow-up: 8 comment:7 by , 11 years ago
Keywords: | initenv added; db admin cli removed |
---|---|
Milestone: | → undecided |
I think you need an option to specify template trac.ini file to initenv
command rather than initializing database like this.
$ trac-admin /path/to/env initenv --template=/path/to/base-env/conf/trac.ini 'Project Name' postgres:///trac
I don't think we should add the initdb
command of trac-admin
.
comment:8 by , 9 years ago
Replying to jomae:
I think you need an option to specify template trac.ini file to
initenv
command rather than initializing database like this.
I've found myself scripting a lot of Trac installs lately that utilize a pre-existing trac.ini file (e.g. Trac upgrades with a clean install, and server migrations). The --template
(or --ini
) option would reduce the number of commands necessary in the script.
With a properly-coded plugin (comment:41:ticket:8172) and all plugins enabled in the template file, the environment upgrade actions would occur in environment_created
and a TracAdmin upgrade would not be necessary.
comment:9 by , 9 years ago
Proposed changes in log:rjollos.git:t11333. I'll add more unit test coverage before committing.
comment:10 by , 9 years ago
Milestone: | undecided → next-major-releases |
---|
comment:11 by , 9 years ago
Cc: | removed |
---|---|
Milestone: | next-major-releases → 1.2 |
Owner: | set to |
Status: | new → assigned |
comment:12 by , 9 years ago
Release Notes: | modified (diff) |
---|
Revised changes in log:rjollos.git:t11333.2.
comment:13 by , 9 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Changes committed with minor modification in [14182,14190].
comment:14 by , 9 years ago
I got a failure of unit tests on Windows.
====================================================================== ERROR: test_config_argument (trac.admin.tests.console.TracAdminInitenvTestCase) Options contained in file specified by the --config argument ---------------------------------------------------------------------- Traceback (most recent call last): File "C:\usr\src\trac\trac.git\trac\admin\tests\console.py", line 1583, in tearDown shutil.rmtree(self.parent_dir) File "C:\usr\apps\python27-amd64\Lib\shutil.py", line 247, in rmtree rmtree(fullname, ignore_errors, onerror) File "C:\usr\apps\python27-amd64\Lib\shutil.py", line 247, in rmtree rmtree(fullname, ignore_errors, onerror) File "C:\usr\apps\python27-amd64\Lib\shutil.py", line 252, in rmtree onerror(os.remove, fullname, sys.exc_info()) File "C:\usr\apps\python27-amd64\Lib\shutil.py", line 250, in rmtree os.remove(fullname) WindowsError: [Error 32] The process cannot access the file beacause it is being used by another process.: 'c:\\users\\omae\\appdata\\local\\temp\\tmpkjwyhe\\trac\\db\\sqlite.db'
The following patch would fix it.
-
trac/admin/tests/console.py
diff --git a/trac/admin/tests/console.py b/trac/admin/tests/console.py index 7a92bd2..d8ab546 100644
a b class TracAdminInitenvTestCase(TracAdminTestCaseBase): 1580 1580 self._admin = TracAdmin(self.env_path) 1581 1581 1582 1582 def tearDown(self): 1583 if os.path.isfile(os.path.join(self.env_path, 'VERSION')): 1584 self._admin.env.shutdown() 1583 1585 shutil.rmtree(self.parent_dir) 1584 1586 1585 1587 def test_config_argument(self):
I'll push it later.
Considering this
… and the fact that
do_initdb
merely forwards the invocation todo_initenv
method I have replaced it's body with code submitted by Ethan Jucovy via trac-dev@… with a few minor modifications listed below .wiki upgrade
To get this done the following patch should be applied .
Open question is whether this should be better implemented as a
trac.env.Environment
method , similar toupgrade
command . If this was the case then I will submit another one aimed at implementing it in the environment instead .In any case this patch provides test cases .
This all is still WiP but still early feedback will be appreciated .