|
| 1 | +# CipherStash Migrator |
| 2 | + |
| 3 | +The CipherStash Migrator is a tool that can be used to migrate plaintext data in a database to its encrypted equivalent. |
| 4 | +It works inside the CipherStash Proxy Docker container and can handle different data types such as text, JSONB, integers, booleans, floats, and dates. |
| 5 | +By specifying the relevant columns in your table, the migrator will seamlessly encrypt the existing data and store it in designated encrypted columns. |
| 6 | + |
| 7 | +## Prerequisites |
| 8 | + |
| 9 | +- [CipherStash Proxy](PROXY.md) |
| 10 | +- [Have set up EQL in your database](GETTINGSTARTED.md) |
| 11 | + - Ensure that the columns where data will be migrated already exist. |
| 12 | + |
| 13 | +Here’s a draft for the technical usage documentation for the CipherStash Migrator tool: |
| 14 | + |
| 15 | +## Usage |
| 16 | + |
| 17 | +The CipherStash Migrator allows you to specify key-value pairs where the key is the plaintext column, and the value is the corresponding encrypted column. |
| 18 | +Multiple key-value pairs can be specified, and the tool will perform a migration for each specified column. |
| 19 | + |
| 20 | +### Running the migrator |
| 21 | + |
| 22 | +You will need to SSH into the CipherStash Proxy Docker container to run the migrator. |
| 23 | + |
| 24 | +```bash |
| 25 | +docker exec -it eql-cipherstash-proxy bash |
| 26 | +``` |
| 27 | + |
| 28 | +Once inside the container, you have access to the migrator tool. |
| 29 | + |
| 30 | +```bash |
| 31 | +cipherstash-migrator --version |
| 32 | +``` |
| 33 | + |
| 34 | +#### Flags |
| 35 | + |
| 36 | +| Flag | Description | Required | |
| 37 | +| --- | --- | --- | |
| 38 | +| `--columns` | Specifies the plaintext columns and their corresponding encrypted columns. The format is `plaintext_column=encrypted_column`. | Yes | |
| 39 | +| `--table` | Specifies the table where the data will be migrated. | Yes | |
| 40 | +| `--database-name` | Specifies the database name. | Yes | |
| 41 | +| `--username` | Specifies the database username. | Yes | |
| 42 | +| `--password` | Specifies the database password. | Yes | |
| 43 | + |
| 44 | +#### Supported data types |
| 45 | + |
| 46 | +- Text |
| 47 | +- JSONB |
| 48 | +- Integer |
| 49 | +- Boolean |
| 50 | +- Float |
| 51 | +- Date |
| 52 | + |
| 53 | +### Example |
| 54 | + |
| 55 | +The following is an example of how to run the migrator with a single column: |
| 56 | + |
| 57 | +```bash |
| 58 | +cipherstash-migrator --columns example_column=example_column_encrypted --table examples --database-name postgres --username postgres --password postgres |
| 59 | +``` |
| 60 | + |
| 61 | +If you require additional data types, please [raise an issue](https://github.com/cipherstash/encrypt-query-language/issues) |
| 62 | + |
| 63 | +### Running migrations with multiple columns |
| 64 | + |
| 65 | +To run a migration on multiple columns at once, specify multiple key-value pairs in the `--columns` option: |
| 66 | + |
| 67 | +```bash |
| 68 | +cipherstash-migrator --columns test_text=encrypted_text test_jsonb=encrypted_jsonb test_int=encrypted_int test_boolean=encrypted_boolean --table examples --database-name migrator_test --username postgres --password postgres |
| 69 | +``` |
| 70 | + |
| 71 | +## Notes |
| 72 | + |
| 73 | +- Ensure that the corresponding encrypted columns already exist in the table before running the migration. |
| 74 | +- Data migration operations should be tested in a development environment before being executed in production. |
0 commit comments