|
| 1 | +--- |
| 2 | +title: "Upgrading Elekto" |
| 3 | +linkTitle: "Upgrading" |
| 4 | +weight: 7 |
| 5 | +description: > |
| 6 | + How to upgrade Elekto |
| 7 | +--- |
| 8 | + |
| 9 | +# Upgrading |
| 10 | + |
| 11 | +In most cases, you should be able to upgrade Elekto just by replacing the |
| 12 | +Python/Flask code or the container image and restarting the service. |
| 13 | +The cases where that is not true are documented below. |
| 14 | + |
| 15 | +If you are running Elekto as Python code, you should also update the |
| 16 | +dependencies every time you upgrade, as we usually upgrade python library |
| 17 | +versions to current ones. |
| 18 | + |
| 19 | +``` |
| 20 | +pip3 install -r requirements.txt |
| 21 | +``` |
| 22 | + |
| 23 | +## Upgrading from 0.5 to 0.6 |
| 24 | + |
| 25 | +**This Upgrade Requires Extra Steps** |
| 26 | + |
| 27 | +Version 0.6 involves several major changes to the database schema which require |
| 28 | +a multi-step database migration. **At this time, this process is only automated |
| 29 | +for PostgreSQL**. |
| 30 | + |
| 31 | +**The Elekto Project Recommends Backing Up Your Database Before Upgrading** |
| 32 | + |
| 33 | +For users on PostgreSQL, the process should be as simple as: |
| 34 | + |
| 35 | +1. Shut the Elekto web application down |
| 36 | +2. Upgrade Elekto software |
| 37 | +3. Run `python console --migrate` |
| 38 | + |
| 39 | +If you are using the official container image, or others built like it, then |
| 40 | +the container image should automatically do the above when you delete and replace |
| 41 | +the container or pod. |
| 42 | + |
| 43 | +This may fail on PostgreSQL, either because you have modified your database schema |
| 44 | +after creation by Elekto, or because the Elekto database user does not have |
| 45 | +permissions to modify tables. In either case, you may need to run the |
| 46 | +database migration manually. If so, you will need to run the following SQL |
| 47 | +statements as the database owner or superuser: |
| 48 | + |
| 49 | +``` |
| 50 | +CREATE TABLE schema_version ( version INT PRIMARY KEY ); |
| 51 | +INSERT INTO schema_version VALUES ( 2 ); |
| 52 | +ALTER TABLE voter ADD COLUMN salt BYTEA, ADD COLUMN ballot_id BYTEA; |
| 53 | +CREATE INDEX voter_election_id ON voter(election_id); |
| 54 | +ALTER TABLE ballot DROP COLUMN created_at, DROP COLUMN updated_at; |
| 55 | +ALTER TABLE ballot DROP CONSTRAINT ballot_pkey; |
| 56 | +ALTER TABLE ballot ALTER COLUMN id TYPE CHAR(32) USING to_char(id , 'FM00000000000000000000000000000000'); |
| 57 | +ALTER TABLE ballot ALTER COLUMN id DROP DEFAULT; |
| 58 | +ALTER TABLE ballot ADD CONSTRAINT ballot_pkey PRIMARY KEY ( id ); |
| 59 | +CREATE INDEX ballot_election_id ON ballot(election_id); |
| 60 | +``` |
| 61 | + |
| 62 | +We [do not yet have instructions](https://github.com/elekto-io/elekto/issues/67) for upgrading MySQL or SQLite. Those are in development. |
| 63 | +If you have an Elekto/MySQL instance, please contact us via Elekto slack channel |
| 64 | +on CNCF Slack, or by [commenting on the issue](https://github.com/elekto-io/elekto/issues/67); we would like to work with you on this. |
| 65 | + |
| 66 | +If you do not care about preserving election history, your other option is |
| 67 | +to simply delete the old database and create a new, empty one. In that case, |
| 68 | +Elekto will generate a new, updated schema through `console --migrate`. |
0 commit comments