Skip to content

Commit 12c7ef1

Browse files
committed
fix: add migration files without embedding to binaries
1 parent d8bd900 commit 12c7ef1

File tree

7 files changed

+33
-3
lines changed

7 files changed

+33
-3
lines changed

.github/workflows/license_headers_check.yml

+1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ jobs:
2626
-s=only \
2727
-ignore '.github/workflows/*.yml' \
2828
-ignore '.github/workflows/*.yaml' \
29+
-ignore 'migrations/*.sql' \
2930
.

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ indexer.toml
88

99
# IDE files
1010
.vscode/
11-
migrations/
11+
# migrations/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- Add down migration script here
2+
DROP TABLE "CostModels";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CREATE TABLE IF NOT EXISTS "CostModels"
2+
(
3+
id INT,
4+
deployment VARCHAR NOT NULL,
5+
model TEXT,
6+
variables JSONB,
7+
PRIMARY KEY( deployment )
8+
);

migrations/README.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Database Migration setup
2+
3+
Indexer service binary does _NOT_ run database migrations automatically in the program binary, as it might introduce conflicts with the migrations run by indexer agent. Indexer agent is solely responsible for syncing and migrating the database.
4+
5+
The migration files here are included here for testing only.
6+
7+
### Prerequisite: Install sqlx-cli
8+
9+
Run `cargo install sqlx-cli --no-default-features --features native-tls,postgres`
10+
11+
Simple option: run general installation that supports all databases supported by SQLx
12+
`cargo install sqlx-cli`
13+
14+
### Run the migration
15+
16+
Run `sqlx migrate run`

service/src/common/indexer_management_client/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub struct QueryRoot;
1616
#[derive(Debug, Clone)]
1717
pub struct IndexerManagementClient {
1818
database: PgPool, // Only referenced
19-
client: Client, // it is Arc
19+
client: Client, // it is Arc
2020
}
2121

2222
impl IndexerManagementClient {

service/src/server/routes/cost.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,8 @@ pub(crate) async fn graphql_handler(
1111
Extension(schema): Extension<CostSchema>,
1212
Extension(server_options): Extension<ServerOptions>,
1313
) -> GraphQLResponse {
14-
schema.execute(req.into_inner().data(server_options)).await.into()
14+
schema
15+
.execute(req.into_inner().data(server_options))
16+
.await
17+
.into()
1518
}

0 commit comments

Comments
 (0)