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
MySQL schema change to support fractional time (#984)
# Pull Request
## Title
MySQL schema change to support fractional time
______________________________________________________________________
## Description
- Changes the storage schema to support a variant for MySQL that can
handle fractional time.
- Adds a custom column comparator to be able to pick that up by default
in the future.
- Adjusts tests to check for fractional time support.
______________________________________________________________________
## Type of Change
- 🛠️ Bug fix
- ✨ New feature
- 🔄 Refactor
- 🧪 Tests
______________________________________________________________________
## Testing
- A lot of manual testing with docker.
- Additional CI tests
- Existing CI tests
______________________________________________________________________
## Additional Notes (optional)
Part of a series of changes, should be merged after #983
______________________________________________________________________
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Copy file name to clipboardExpand all lines: mlos_bench/mlos_bench/storage/sql/alembic/README.md
+104-9Lines changed: 104 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,49 +4,144 @@ 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 `mlos_bench.sqlite`database file in the [`mlos_bench/storage/sql`](../) directory with the current schema using the following command:
7
+
1. Create a blank database instance in the [`mlos_bench/storage/sql`](../) directory with the current schema using the following command:
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.
38
104
39
105
Examine the results using something like:
40
106
41
107
```sh
108
+
# For sqlite:
42
109
sqlite3 mlos_bench.sqlite .schema
43
110
sqlite3 mlos_bench.sqlite "SELECT * FROM alembic_version;"
44
111
```
45
112
113
+
```sh
114
+
# For mysql:
115
+
mysql --user root --password=password --host localhost --protocol tcp --database mlos_bench -e "SHOW TABLES; SELECT * FROM alembic_version;"
116
+
```
117
+
118
+
```sh
119
+
# For postgres:
120
+
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;"
121
+
```
122
+
123
+
> Use different CLI clients for targeting other engines.
124
+
46
125
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.
47
126
48
127
> Be sure to update the latest version in the [`test_storage_schemas.py`](../../../tests/storage/sql/test_storage_schemas.py) file as well.
49
128
129
+
1. Cleanup any server instances you started.
130
+
131
+
For instance:
132
+
133
+
```sh
134
+
rm mlos_bench/storage/sql/mlos_bench.sqlite
135
+
```
136
+
137
+
```sh
138
+
docker kill mysql-alembic
139
+
```
140
+
141
+
```sh
142
+
docker kill postgres-alembic
143
+
```
144
+
50
145
1. Merge that to the `main` branch.
51
146
52
147
1. Might be good to cut a new `mlos_bench` release at this point as well.
0 commit comments