Skip to content

Commit aa463a3

Browse files
authored
Namespace the migrations under the pgml schema (#524)
Co-authored-by: Montana Low <montana.low@gmail.com>
1 parent c0d7a93 commit aa463a3

17 files changed

+394
-355
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ The dashboard makes it easy to compare different algorithms or hyperparameters a
4444
See it in action — <a href="https://cloud.postgresml.org/" target="_blank">cloud.postgresml.org</a>
4545
</h2>
4646

47+
Please see the [quick start instructions](https://postgresml.org/user_guides/setup/quick_start_with_docker/) for general information on installing or deploying PostgresML. A [developer guide](https://postgresml.org/developer_guide/overview/) is also available for those who would like to contribute.
48+
4749
## What's in the box
4850
See the documentation for a complete **[list of functionality](https://postgresml.org/)**.
4951

pgml-dashboard/README.md

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,4 @@
22

33
PostgresML provides a dashboard with analytical views of the training data and model performance, as well as integrated notebooks for rapid iteration. It is primarily written in Rust using [Rocket](https://rocket.rs/) as a lightweight web framework and [SQLx](https://github.com/launchbadge/sqlx) to interact with the database.
44

5-
Please see the [online documentation](https://postgresml.org/user_guides/setup/quick_start_with_docker/) for general information on installing or deploying PostgresML. This document is intended to help developers set up a local copy of the dashboard.
6-
7-
## Requirements
8-
9-
The dashboard requires a Postgres database with the [pgml-extension](https://github.com/postgresml/postgresml/tree/master/pgml-extension) to generate the core schema. See that subproject for developer setup.
10-
11-
We develop and test this web application on Linux, OS X, and Windows using WSL2.
12-
13-
## Build process
14-
15-
You'll need to specify a database url for the extension to interact with via an environment variable:
16-
17-
```commandline
18-
export DATABASE_URL=postgres://user_name:password@localhost:5432/database_name
19-
```
20-
21-
Build and run:
22-
23-
```commandline
24-
cargo run
25-
```
26-
27-
Incremental and automatic compilation for development cycles is supported with:
28-
29-
```commandline
30-
cargo watch --exec run
31-
```
32-
33-
Run tests:
34-
```commandline
35-
cargo test
36-
```
5+
Please see the [quick start instructions](https://postgresml.org/user_guides/setup/quick_start_with_docker/) for general information on installing or deploying PostgresML. A [developer guide](https://postgresml.org/developer_guide/overview/) is also available for those who would like to contribute.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
-- Add down migration script here
2-
DROP TABLE notebook_cells;
3-
DROP TABLE notebooks;
2+
DROP TABLE pgml.notebook_cells;
3+
DROP TABLE pgml.notebooks;

pgml-dashboard/migrations/20221125201109_notebook.up.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
-- Add up migration script here
2-
CREATE TABLE notebooks (
2+
CREATE TABLE pgml.notebooks (
33
id BIGSERIAL PRIMARY KEY,
44
name VARCHAR NOT NULL,
55
created_at TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT NOW(),
66
updated_at TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT NOW()
77
);
88

9-
CREATE TABLE notebook_cells (
9+
CREATE TABLE pgml.notebook_cells (
1010
id BIGSERIAL PRIMARY KEY,
11-
notebook_id BIGINT NOT NULL REFERENCES notebooks(id),
11+
notebook_id BIGINT NOT NULL REFERENCES pgml.notebooks(id),
1212
cell_type INT NOT NULL,
1313
cell_number INT NOT NULL,
1414
version INT NOT NULL,
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
-- Add down migration script here
2-
TRUNCATE notebook_cells CASCADE;
3-
TRUNCATE notebooks CASCADE;
2+
TRUNCATE pgml.notebook_cells CASCADE;
3+
TRUNCATE pgml.notebooks CASCADE;

pgml-dashboard/migrations/20221129170843_notebooks_data.up.sql

Lines changed: 183 additions & 183 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
-- Add down migration script here
2-
DROP TABLE uploaded_files;
2+
DROP TABLE pgml.uploaded_files;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-- Add up migration script here
22
-- Add up migration script here
3-
CREATE TABLE uploaded_files (
3+
CREATE TABLE pgml.uploaded_files (
44
id BIGSERIAL PRIMARY KEY,
55
created_at TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT NOW()
66
);

pgml-dashboard/src/guards.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,6 @@ impl<'r> FromRequest<'r> for Cluster {
5656
pub fn default_database_url() -> String {
5757
match var("DATABASE_URL") {
5858
Ok(val) => val,
59-
Err(_) => "postgres:///dashboard".to_string(),
59+
Err(_) => "postgres:///pgml".to_string(),
6060
}
6161
}

pgml-dashboard/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ mod templates;
2222

2323
use guards::Cluster;
2424
use responses::{BadRequest, ResponseOk};
25+
use sqlx::Executor;
2526

2627
/// This struct contains information specific to the cluster being displayed in the dashboard.
2728
///
@@ -50,6 +51,10 @@ impl Clusters {
5051
.max_connections(5)
5152
.idle_timeout(std::time::Duration::from_millis(15_000))
5253
.min_connections(0)
54+
.after_connect(|conn, _meta| Box::pin(async move {
55+
conn.execute("SET application_name = 'pgml_dashboard';").await?;
56+
Ok(())
57+
}))
5358
.connect_lazy(database_url)?;
5459

5560
pools.insert(cluster_id, pool.clone());

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy