mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-11 16:09:39 +00:00
chore(datatable-migrations): remove unused update_datatable_migrations endpoint
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
f8c216d301
commit
072f2bf053
-19
@@ -1,19 +0,0 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO datatable_migrations (workspace_id, datatable, timestamp, name, code_up, code_down) SELECT $1, * FROM UNNEST($2::varchar[], $3::bigint[], $4::varchar[], $5::text[], $6::text[])",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Varchar",
|
||||
"VarcharArray",
|
||||
"Int8Array",
|
||||
"VarcharArray",
|
||||
"TextArray",
|
||||
"TextArray"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "98f03bde861caf75a4a98457fe9dc1c25362de35ef086731095bac0e7e679a48"
|
||||
}
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "DELETE FROM datatable_migrations WHERE workspace_id = $1",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "c5d7ecfb865d05cee3d9d185cfee424163ea4693684bbf9c511c0c5afb6537f1"
|
||||
}
|
||||
@@ -51,10 +51,6 @@ pub(crate) fn routes() -> Router {
|
||||
post(rollback_datatable_migrations),
|
||||
)
|
||||
.route("/list_datatable_migrations", get(list_datatable_migrations))
|
||||
.route(
|
||||
"/update_datatable_migrations",
|
||||
post(update_datatable_migrations),
|
||||
)
|
||||
.route(
|
||||
"/datatable_migrations_status/{datatable_name}",
|
||||
get(datatable_migrations_status),
|
||||
@@ -513,84 +509,6 @@ async fn list_datatable_migrations(
|
||||
Ok(Json(migrations))
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct UpdateDatatableMigrations {
|
||||
pub migrations: Vec<DatatableMigration>,
|
||||
}
|
||||
|
||||
/// Replace the workspace's whole set of data table migrations with the provided
|
||||
/// list. Used by `wmill sync` to push the `migrations/datatable/` folder.
|
||||
async fn update_datatable_migrations(
|
||||
authed: ApiAuthed,
|
||||
Extension(db): Extension<DB>,
|
||||
Path(w_id): Path<String>,
|
||||
Json(payload): Json<UpdateDatatableMigrations>,
|
||||
) -> Result<String> {
|
||||
for m in &payload.migrations {
|
||||
validate_datatable_path_segment(&m.datatable)?;
|
||||
validate_migration_name(&m.name)?;
|
||||
}
|
||||
|
||||
let datatables: Vec<String> = payload
|
||||
.migrations
|
||||
.iter()
|
||||
.map(|m| m.datatable.clone())
|
||||
.collect();
|
||||
let timestamps: Vec<i64> = payload.migrations.iter().map(|m| m.timestamp).collect();
|
||||
let names: Vec<String> = payload.migrations.iter().map(|m| m.name.clone()).collect();
|
||||
let code_ups: Vec<String> = payload
|
||||
.migrations
|
||||
.iter()
|
||||
.map(|m| m.code_up.clone())
|
||||
.collect();
|
||||
let code_downs: Vec<Option<String>> = payload
|
||||
.migrations
|
||||
.iter()
|
||||
.map(|m| m.code_down.clone())
|
||||
.collect();
|
||||
|
||||
let mut tx = db.begin().await?;
|
||||
|
||||
sqlx::query!(
|
||||
"DELETE FROM datatable_migrations WHERE workspace_id = $1",
|
||||
&w_id
|
||||
)
|
||||
.execute(&mut *tx)
|
||||
.await?;
|
||||
|
||||
sqlx::query!(
|
||||
"INSERT INTO datatable_migrations (workspace_id, datatable, timestamp, name, code_up, code_down) \
|
||||
SELECT $1, * FROM UNNEST($2::varchar[], $3::bigint[], $4::varchar[], $5::text[], $6::text[])",
|
||||
&w_id,
|
||||
&datatables,
|
||||
×tamps,
|
||||
&names,
|
||||
&code_ups,
|
||||
&code_downs as &[Option<String>],
|
||||
)
|
||||
.execute(&mut *tx)
|
||||
.await?;
|
||||
|
||||
audit_log(
|
||||
&mut *tx,
|
||||
&authed,
|
||||
"workspaces.update_datatable_migrations",
|
||||
ActionKind::Update,
|
||||
&w_id,
|
||||
Some(&authed.email),
|
||||
Some([("count", payload.migrations.len().to_string().as_str())].into()),
|
||||
)
|
||||
.await?;
|
||||
|
||||
tx.commit().await?;
|
||||
|
||||
Ok(format!(
|
||||
"Updated {} datatable migration(s) for workspace {}",
|
||||
payload.migrations.len(),
|
||||
&w_id
|
||||
))
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
enum DatatableMigrationRunStatus {
|
||||
|
||||
@@ -4728,34 +4728,6 @@ paths:
|
||||
items:
|
||||
$ref: "#/components/schemas/DatatableMigration"
|
||||
|
||||
/w/{workspace}/workspaces/update_datatable_migrations:
|
||||
post:
|
||||
summary: replace the workspace's datatable migrations
|
||||
operationId: updateDatatableMigrations
|
||||
tags:
|
||||
- workspace
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/WorkspaceId"
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
required: [migrations]
|
||||
properties:
|
||||
migrations:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/DatatableMigration"
|
||||
responses:
|
||||
"200":
|
||||
description: status
|
||||
content:
|
||||
text/plain:
|
||||
schema:
|
||||
type: string
|
||||
|
||||
/w/{workspace}/workspaces/datatable_migrations_status/{datatable_name}:
|
||||
get:
|
||||
summary: list a datatable's migrations with their applied status
|
||||
|
||||
Reference in New Issue
Block a user