Skip to content

Commit

Permalink
merge: #3494
Browse files Browse the repository at this point in the history
3494: Annihilate all unsued migrations and queries in the dal (ENG-2435) r=nickgerace a=nickgerace

## Description

This is it. Since merging the new engine onto main, we have kept around migrations and queries to help restore functionality in the system. We're now at a point where we can destroy the bulk of our old migrations and queries. You all served us well.

<img src="https://media1.giphy.com/media/l1Kugz3C30dJmxmUw/giphy.gif"/>

## Additional or Noteworthy Changes

- Move and rename all remaining queries to subdirectories based on which tables they reference
- Remove dead code related to migrations and queries
- Modify func-related and validation-related migrations to work since they are still used a hybrid fashion
- Make `FuncBinding` methods private that can be made private
- Fix "todo" for missing builtin workspace
- Fix "get_diff" integration test final assertion



Co-authored-by: Nick Gerace <[email protected]>
  • Loading branch information
si-bors-ng[bot] and nickgerace authored Apr 2, 2024
2 parents e8d9f65 + 4712916 commit bbd1995
Show file tree
Hide file tree
Showing 120 changed files with 78 additions and 12,321 deletions.
32 changes: 5 additions & 27 deletions lib/dal/src/func/binding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use tokio::sync::mpsc;
use veritech_client::{BeforeFunction, OutputStream, ResolverFunctionComponent};

use super::FuncError;
use crate::func::execution::FuncExecutionPk;
use crate::{
func::backend::FuncBackendError, impl_standard_model, pk, standard_model,
standard_model_accessor, Func, FuncBackendKind, HistoryEventError, StandardModel,
Expand Down Expand Up @@ -145,28 +144,6 @@ impl FuncBinding {
Ok(object)
}

pub async fn create_with_existing_value(
ctx: &DalContext,
args: serde_json::Value,
value: Option<serde_json::Value>,
func_id: FuncId,
) -> FuncBindingResult<(Self, FuncBindingReturnValue)> {
let func = Func::get_by_id(ctx, func_id).await?;
let func_binding = Self::new(ctx, args, func_id, func.backend_kind).await?;

let func_binding_return_value = FuncBindingReturnValue::new(
ctx,
value.clone(),
value,
func_id,
*func_binding.id(),
FuncExecutionPk::NONE,
)
.await?;

Ok((func_binding, func_binding_return_value))
}

/// Runs [`Self::new()`] and executes.
///
/// Use this function if you would like to receive the
Expand All @@ -191,7 +168,8 @@ impl FuncBinding {
standard_model_accessor!(backend_kind, Enum(FuncBackendKind), FuncBindingResult);
standard_model_accessor!(code_blake3, String, FuncBindingResult);
standard_model_accessor!(func_id, Pk(FuncId), FuncBindingResult);
// For a given [`FuncBinding`](Self), execute using veritech.

/// Execute using veritech.
async fn execute(
&self,
ctx: &DalContext,
Expand All @@ -213,7 +191,7 @@ impl FuncBinding {

/// Perform function execution to veritech for a given [`Func`](crate::Func) and
/// [`FuncDispatchContext`](crate::func::backend::FuncDispatchContext).
pub async fn execute_critical_section(
async fn execute_critical_section(
&self,
func: Func,
context: FuncDispatchContext,
Expand Down Expand Up @@ -290,7 +268,7 @@ impl FuncBinding {
}
}

pub async fn postprocess_execution(
async fn postprocess_execution(
&self,
ctx: &DalContext,
output_stream: Vec<OutputStream>,
Expand Down Expand Up @@ -323,7 +301,7 @@ impl FuncBinding {
Ok(func_binding_return_value)
}

pub async fn prepare_execution(
async fn prepare_execution(
&self,
ctx: &DalContext,
) -> FuncBindingResult<(
Expand Down
20 changes: 0 additions & 20 deletions lib/dal/src/installed_pkg/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ use strum::{AsRefStr, Display, EnumIter, EnumString};
const LIST_FOR_KIND_AND_HASH: &str =
include_str!("../queries/installed_pkg/list_asset_for_kind_and_hash.sql");

const LIST_FOR_INSTALLED_PKG_ID: &str =
include_str!("../queries/installed_pkg/list_asset_for_installed_pkg_id.sql");

pk!(InstalledPkgAssetPk);
pk!(InstalledPkgAssetId);
pk!(InstalledPkgAssetAssetId);
Expand Down Expand Up @@ -346,23 +343,6 @@ impl InstalledPkgAsset {
}
}

pub async fn list_for_installed_pkg_id(
ctx: &DalContext,
installed_pkg_id: InstalledPkgId,
) -> InstalledPkgResult<Vec<Self>> {
let rows = ctx
.txns()
.await?
.pg()
.query(
LIST_FOR_INSTALLED_PKG_ID,
&[ctx.tenancy(), ctx.visibility(), &installed_pkg_id],
)
.await?;

Ok(standard_model::objects_from_rows(rows)?)
}

pub async fn list_for_kind_and_hash(
ctx: &DalContext,
kind: InstalledPkgAssetKind,
Expand Down
25 changes: 3 additions & 22 deletions lib/dal/src/key_pair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use crate::{

mod key_pair_box_public_key_serde;

const PUBLIC_KEY_GET_CURRENT: &str = include_str!("./queries/public_key_get_current.sql");
const KEY_PAIR_GET_BY_PK: &str = include_str!("queries/key_pair_get_by_pk.sql");
const GET_BY_PK: &str = include_str!("queries/key_pair/get_by_pk.sql");
const PUBLIC_KEY_GET_CURRENT: &str = include_str!("./queries/key_pair/public_key_get_current.sql");

#[remain::sorted]
#[derive(Error, Debug)]
Expand Down Expand Up @@ -107,26 +107,7 @@ impl KeyPair {
}

pub async fn get_by_pk(ctx: &DalContext, pk: KeyPairPk) -> KeyPairResult<Self> {
let row = ctx
.txns()
.await?
.pg()
.query_one(KEY_PAIR_GET_BY_PK, &[&pk])
.await?;
let json: serde_json::Value = row.try_get("object")?;
let key_pair_row: KeyPairRow = serde_json::from_value(json)?;
let key_pair = key_pair_row.decrypt_into(ctx.symmetric_crypto_service())?;
Ok(key_pair)
}

pub async fn get_current(ctx: &DalContext) -> KeyPairResult<Self> {
let row = ctx
.txns()
.await?
.pg()
.query_one(PUBLIC_KEY_GET_CURRENT, &[&ctx.tenancy().workspace_pk()])
.await?;

let row = ctx.txns().await?.pg().query_one(GET_BY_PK, &[&pk]).await?;
let json: serde_json::Value = row.try_get("object")?;
let key_pair_row: KeyPairRow = serde_json::from_value(json)?;
let key_pair = key_pair_row.decrypt_into(ctx.symmetric_crypto_service())?;
Expand Down
53 changes: 0 additions & 53 deletions lib/dal/src/migrations/U0031__schema.sql

This file was deleted.

53 changes: 0 additions & 53 deletions lib/dal/src/migrations/U0032__schema_ui_menus.sql

This file was deleted.

43 changes: 0 additions & 43 deletions lib/dal/src/migrations/U0033__schema_variants.sql

This file was deleted.

55 changes: 0 additions & 55 deletions lib/dal/src/migrations/U0034__sockets.sql

This file was deleted.

Loading

0 comments on commit bbd1995

Please sign in to comment.