Skip to content

Commit

Permalink
Fix #117: Enhance migration docs for new db naming
Browse files Browse the repository at this point in the history
- Enhance the migration guide
- Add prerequisite sql
  • Loading branch information
jandusil committed Sep 27, 2023
1 parent b9dc6c1 commit 2a6c29b
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 29 deletions.
79 changes: 50 additions & 29 deletions docs/PowerAuth-Mobile-Utility-Server-1.5.0.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,36 @@
## Migration from 1.4.0 to 1.5.x
# Migration from 1.4.0 to 1.5.x

This guide contains instructions for migration from PowerAuth Server version 1.4.0 to version 1.5.x.
This guide provides step-by-step instructions for migrating from PowerAuth Mobile Utility Server version 1.4.0 to
version 1.5.x.

### Prerequisites
## Prerequisites

Before performing the migration, users are advised to run the associated Liquibase scripts. Once the Liquibase scripts
have been executed successfully, proceed with the steps in the "Database Changes" section below and run
the `1.5.x-migration.sql` script.
Before you begin the migration, ensure you have the necessary SQL scripts and the Liquibase tool available. Depending on
your database type, the scripts can be located in `./docs/sql/oracle` or `./docs/sql/postgresql`.

### Database Changes
## Migration Steps

#### Data Migration between Tables
1. **Stop the Application**: Ensure that the PowerAuth Mobile Utility Server application is not running. Shut it down if
it's currently
active.

Migration involves copying data from old tables to new tables and subsequently deleting the old tables. Below are the
SQL commands used for this process:

```sql
-- Migrate data
-- TABLES
2. **Execute Pre-Migration Script**: Navigate to the appropriate SQL scripts directory based on your database type. Run
the `1.5.x-migration-before.sql` script.

-- For table mobile_app
INSERT INTO mus_mobile_app SELECT * FROM ssl_mobile_app;

-- For table mobile_app_version
INSERT INTO mus_mobile_app_version SELECT * FROM ssl_mobile_app_version;
3. **Run Liquibase Commands**: Use the Liquibase tool to apply database changes. Run the following command
script `docker-db-update.sh`.

-- For table mobile_domain
INSERT INTO mus_mobile_domain SELECT * FROM ssl_mobile_domain;

-- For table user
INSERT INTO mus_user SELECT * FROM ssl_user;
4. **Execute Post-Migration Script**: After the Liquibase changes are applied, run the `1.5.x-migration-after.sql`
script located in the same directory as the pre-migration script.

-- For table user_authority
INSERT INTO mus_user_authority SELECT * FROM ssl_user_authority;

-- For table certificate
INSERT INTO mus_certificate SELECT * FROM ssl_certificate;
5. **Start the Application**: Once all the database changes are successfully applied, you can restart the PowerAuth
Server application.

-- For table localized_text
INSERT INTO mus_localized_text SELECT * FROM ssl_localized_text;
```
## Database Changes - overview

#### Drop Old Tables

Expand All @@ -58,7 +49,7 @@ DROP TABLE ssl_user_authority CASCADE;

#### Drop Old Sequences

Similarly, old sequences associated with the dropped tables can be removed:
Similarly, old sequences associated with the dropped tables will be removed:

```sql
-- Drop old sequences
Expand All @@ -70,6 +61,36 @@ DROP SEQUENCE ssl_user_authority_seq CASCADE;
DROP SEQUENCE ssl_user_seq CASCADE;
```

### Data Migration between Tables

Migration involves copying data from old tables to new tables and subsequently deleting the old tables.

```sql
-- Migrate data
-- TABLES

-- For table mobile_app
INSERT INTO mus_mobile_app SELECT * FROM ssl_mobile_app;

-- For table mobile_app_version
INSERT INTO mus_mobile_app_version SELECT * FROM ssl_mobile_app_version;

-- For table mobile_domain
INSERT INTO mus_mobile_domain SELECT * FROM ssl_mobile_domain;

-- For table user
INSERT INTO mus_user SELECT * FROM ssl_user;

-- For table user_authority
INSERT INTO mus_user_authority SELECT * FROM ssl_user_authority;

-- For table certificate
INSERT INTO mus_certificate SELECT * FROM ssl_certificate;

-- For table localized_text
INSERT INTO mus_localized_text SELECT * FROM ssl_localized_text;
```

### Conclusion

After executing the above SQL commands successfully, the migration process is complete. Ensure to verify and test the
Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions docs/sql/oracle/1.5.x-migration-before.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Drop liquibase tracking tables
DROP TABLE databasechangelog CASCADE CONSTRAINTS;
DROP TABLE databasechangeloglock CASCADE CONSTRAINTS;

File renamed without changes.
4 changes: 4 additions & 0 deletions docs/sql/postgresql/1.5.x-migration-before.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Drop liquibase tracking tables
DROP TABLE databasechangelog CASCADE;
DROP TABLE databasechangeloglock CASCADE;

0 comments on commit 2a6c29b

Please sign in to comment.