Skip to content

Commit fe96a40

Browse files
committed
WIP: docs: start writing upgrade guide
1 parent a841b14 commit fe96a40

1 file changed

Lines changed: 129 additions & 0 deletions

File tree

docs/upgrading.rst

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
..
2+
This file is part of Invenio.
3+
Copyright (C) 2025 CERN.
4+
5+
Invenio is free software; you can redistribute it and/or modify it
6+
under the terms of the MIT License; see LICENSE file for more details.
7+
8+
Upgrading
9+
=========
10+
11+
======
12+
v4.0.0
13+
======
14+
15+
This version consists of a major refactor of the module and a full rename to ``invenio-vcs`` (from ``invenio-github``).
16+
The new version has now been made generic and can support any VCS provider by implementing the relevant abstract classes.
17+
18+
Contrib implementations are provided for GitHub and GitLab.
19+
GitHub is supported with the exact same set of features as before, meaning this module can continue to be used for the original
20+
purpose of ``invenio-github`` with just some migrations and configuration changes required.
21+
22+
Please follow this guide if:
23+
24+
- you are **not** using InvenioRDM; or
25+
- you would like to try out ``invenio-vcs`` before InvenioRDM v14 is released.
26+
27+
- This is not officially supported but should work for the most part.
28+
29+
RDM-specific instructions can instead be found in the `InvenioRDM upgrade guide <https://inveniordm.docs.cern.ch/releases/vNext/upgrade-vNext/>`_.
30+
31+
--------------------------
32+
1. Update the dependencies
33+
--------------------------
34+
35+
In your ``Pipfile`` (or any similar file you are using to manage dependencies), change the name and version of the ``invenio-vcs`` packages.
36+
Additionally, you will need to ensure some other dependencies are up to date for compatibility with the new changes.
37+
38+
.. code-block:: toml
39+
40+
[packages]
41+
# ...
42+
invenio-vcs = ">=4.0.0,<5.0.0"
43+
invenio-rdm-records = "TODO"
44+
invenio-app-rdm = "TODO"
45+
invenio-oauthclient = "TODO"
46+
47+
.. note::
48+
49+
``invenio-vcs`` is no longer packaged by default with InvenioRDM, as was the case with ``invenio-github``.
50+
You must declare it as an explicit dependency on the instance level.
51+
52+
Next, run the install operation and make sure the old module is no longer installed.
53+
Having both installed simultaneously will lead to numerous conflicts, especially with Alembic migrations.
54+
55+
.. code-block:: bash
56+
57+
invenio-cli install
58+
pip uninstall invenio-github
59+
60+
----------------------------------
61+
2. Perform the database migrations
62+
----------------------------------
63+
64+
Depending on the size of your instance, the migrations can be performed either automatically by running an Alembic script, or manually by
65+
carefully following the instructions in this guide.
66+
67+
If your instance meets one of these criteria, please use the manual method to avoid database stability issues:
68+
69+
- An ``oauthclient_remoteaccount`` table with more than 50k rows
70+
- A ``github_repositories`` table with more than 100k rows
71+
72+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
73+
2a. Automated Alembic script
74+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
75+
76+
Run the upgrade command:
77+
78+
.. code-block:: bash
79+
80+
pipenv run invenio alembic upgrade
81+
82+
^^^^^^^^^^^^^^^^^
83+
2b. Manual method
84+
^^^^^^^^^^^^^^^^^
85+
86+
.. code-block:: sql
87+
88+
BEGIN;
89+
ALTER TABLE github_repositories RENAME TO vcs_repositories;
90+
ALTER TABLE vcs_repositories ALTER COLUMN github_id TYPE VARCHAR(255);
91+
ALTER TABLE vcs_repositories ALTER COLUMN github_id SET NOT NULL;
92+
ALTER TABLE vcs_repositories RENAME github_id TO provider_id;
93+
ALTER TABLE vcs_repositories ALTER COLUMN hook TYPE VARCHAR(255);
94+
ALTER TABLE vcs_repositories ALTER COLUMN hook DROP NOT NULL;
95+
ALTER TABLE vcs_repositories ADD COLUMN provider VARCHAR(255) DEFAULT 'github' NOT NULL;
96+
ALTER TABLE vcs_repositories ADD COLUMN default_branch VARCHAR(255) DEFAULT 'master' NOT NULL;
97+
ALTER TABLE vcs_repositories ADD COLUMN description VARCHAR(10000);
98+
ALTER TABLE vcs_repositories ADD COLUMN html_url VARCHAR(10000);
99+
ALTER TABLE vcs_repositories ADD COLUMN license_spdx VARCHAR(255);
100+
ALTER TABLE vcs_repositories RENAME user_id TO enabled_by_id;
101+
DROP INDEX ix_github_repositories_name;
102+
DROP INDEX ix_github_repositories_github_id;
103+
ALTER TABLE vcs_repositories ADD CONSTRAINT uq_vcs_repositories_provider_provider_id UNIQUE (provider, provider_id);
104+
ALTER TABLE vcs_repositories ADD CONSTRAINT uq_vcs_repositories_provider_name UNIQUE (provider, name);
105+
COMMIT;
106+
107+
Do some things here
108+
109+
.. code-block:: sql
110+
111+
BEGIN;
112+
ALTER TABLE vcs_repositories ALTER COLUMN html_url SET NOT NULL;
113+
ALTER TABLE github_releases RENAME TO vcs_releases;
114+
ALTER TABLE vcs_releases ALTER COLUMN release_id TYPE VARCHAR(255);
115+
ALTER TABLE vcs_releases ALTER COLUMN release_id SET NOT NULL;
116+
ALTER TABLE vcs_releases RENAME release_id TO provider_id;
117+
ALTER TABLE vcs_releases ADD COLUMN provider VARCHAR(255) DEFAULT 'github' NOT NULL;
118+
ALTER TABLE vcs_releases ALTER COLUMN errors TYPE JSONB USING errors::text::jsonb;
119+
ALTER TABLE vcs_releases DROP CONSTRAINT uq_github_releases_release_id;
120+
ALTER TABLE vcs_releases ADD CONSTRAINT uq_vcs_releases_provider_id_provider UNIQUE (provider_id, provider);
121+
ALTER TABLE vcs_releases ADD CONSTRAINT uq_vcs_releases_provider_id_provider_tag UNIQUE (provider_id, provider, tag);
122+
CREATE TABLE vcs_repository_users (
123+
repository_id UUID NOT NULL,
124+
user_id INTEGER NOT NULL,
125+
PRIMARY KEY (repository_id, user_id),
126+
CONSTRAINT fk_vcs_repository_users_repository_id_vcs_repositories FOREIGN KEY(repository_id) REFERENCES vcs_repositories (id),
127+
CONSTRAINT fk_vcs_repository_users_user_id_accounts_user FOREIGN KEY(user_id) REFERENCES accounts_user (id)
128+
);
129+
COMMIT;

0 commit comments

Comments
 (0)