You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: mlos_bench/mlos_bench/storage/sql/alembic/README.md
+9-95Lines changed: 9 additions & 95 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,67 +4,17 @@ This document contains some notes on how to use [`alembic`](https://alembic.sqla
4
4
5
5
## Overview
6
6
7
-
1. Create a blank database instance in the [`mlos_bench/storage/sql`](../) directory with the current schema using the following command:
7
+
1. Create a blank `mlos_bench.sqlite`database file in the [`mlos_bench/storage/sql`](../) directory with the current schema using the following command:
8
8
9
-
This allows `alembic` to automatically generate a migration script from the current schema.
10
-
11
-
> NOTE: If your schema changes target a particular backend engine (e.g., using `with_variant`) you will need to use an engine with that config for this step.
12
-
> \
13
-
> In the remainder of this document we should some examples for different DB types.
14
-
> Pick the one you're targeting and stick with it thru the example.
15
-
> You may need to repeat the process several times to test all of them.
16
-
>
17
-
> -[ ] TODO: Add scripts to automatically do this for several different backend engines all at once.
18
-
19
-
For instance:
20
-
21
-
1. Start a temporary server either as a local file or in a docker instance
> Normally this would be done with `alembic upgrade head`, but this command is convenient to ensure if will work with the `mlos_bench` command line interface as well.
99
38
100
39
Examine the results using something like:
101
40
102
41
```sh
103
-
# For sqlite:
104
42
sqlite3 mlos_bench.sqlite .schema
105
43
sqlite3 mlos_bench.sqlite "SELECT * FROM alembic_version;"
106
44
```
107
45
108
-
```sh
109
-
# For mysql:
110
-
mysql --user root --password=password --host localhost --protocol tcp --database mlos_bench -e "SHOW TABLES; SELECT * FROM alembic_version;"
111
-
```
112
-
113
-
```sh
114
-
# For postgres:
115
-
PGPASSWORD=password psql -h localhost -p 5432 -U postgres mlos_bench -c "SELECT table_name FROM information_schema.tables WHERE table_schema='public' and table_catalog='mlos_bench'; SELECT * FROM alembic_version;"
116
-
```
117
-
118
-
> Use different CLI clients for targeting other engines.
119
-
120
46
1. If the migration script works, commit the changes to the [`mlos_bench/storage/sql/schema.py`](../schema.py) and [`mlos_bench/storage/sql/alembic/versions`](./versions/) files.
121
47
122
48
> Be sure to update the latest version in the [`test_storage_schemas.py`](../../../tests/storage/test_storage_schemas.py) file as well.
123
49
124
-
1. Cleanup any server instances you started.
125
-
126
-
For instance:
127
-
128
-
```sh
129
-
rm mlos_bench/storage/sql/mlos_bench.sqlite
130
-
```
131
-
132
-
```sh
133
-
docker kill mysql-alembic
134
-
```
135
-
136
50
1. Merge that to the `main` branch.
137
51
138
52
1. Might be good to cut a new `mlos_bench` release at this point as well.
0 commit comments