Make all tests pass again after migration to sea-orm
This commit is contained in:
parent
48b6ee313f
commit
7502558631
2 changed files with 89 additions and 71 deletions
|
@ -10,7 +10,7 @@ ALTER TABLE "projects"
|
||||||
|
|
||||||
CREATE TABLE "worktrees" (
|
CREATE TABLE "worktrees" (
|
||||||
"project_id" INTEGER NOT NULL REFERENCES projects (id) ON DELETE CASCADE,
|
"project_id" INTEGER NOT NULL REFERENCES projects (id) ON DELETE CASCADE,
|
||||||
"id" INTEGER NOT NULL,
|
"id" INT8 NOT NULL,
|
||||||
"root_name" VARCHAR NOT NULL,
|
"root_name" VARCHAR NOT NULL,
|
||||||
"abs_path" VARCHAR NOT NULL,
|
"abs_path" VARCHAR NOT NULL,
|
||||||
"visible" BOOL NOT NULL,
|
"visible" BOOL NOT NULL,
|
||||||
|
@ -23,7 +23,7 @@ CREATE INDEX "index_worktrees_on_project_id" ON "worktrees" ("project_id");
|
||||||
CREATE TABLE "worktree_entries" (
|
CREATE TABLE "worktree_entries" (
|
||||||
"project_id" INTEGER NOT NULL,
|
"project_id" INTEGER NOT NULL,
|
||||||
"worktree_id" INT8 NOT NULL,
|
"worktree_id" INT8 NOT NULL,
|
||||||
"id" INTEGER NOT NULL,
|
"id" INT8 NOT NULL,
|
||||||
"is_dir" BOOL NOT NULL,
|
"is_dir" BOOL NOT NULL,
|
||||||
"path" VARCHAR NOT NULL,
|
"path" VARCHAR NOT NULL,
|
||||||
"inode" INT8 NOT NULL,
|
"inode" INT8 NOT NULL,
|
||||||
|
@ -39,9 +39,9 @@ CREATE INDEX "index_worktree_entries_on_project_id_and_worktree_id" ON "worktree
|
||||||
|
|
||||||
CREATE TABLE "worktree_diagnostic_summaries" (
|
CREATE TABLE "worktree_diagnostic_summaries" (
|
||||||
"project_id" INTEGER NOT NULL,
|
"project_id" INTEGER NOT NULL,
|
||||||
"worktree_id" INTEGER NOT NULL,
|
"worktree_id" INT8 NOT NULL,
|
||||||
"path" VARCHAR NOT NULL,
|
"path" VARCHAR NOT NULL,
|
||||||
"language_server_id" INTEGER NOT NULL,
|
"language_server_id" INT8 NOT NULL,
|
||||||
"error_count" INTEGER NOT NULL,
|
"error_count" INTEGER NOT NULL,
|
||||||
"warning_count" INTEGER NOT NULL,
|
"warning_count" INTEGER NOT NULL,
|
||||||
PRIMARY KEY(project_id, worktree_id, path),
|
PRIMARY KEY(project_id, worktree_id, path),
|
||||||
|
@ -52,7 +52,7 @@ CREATE INDEX "index_worktree_diagnostic_summaries_on_project_id_and_worktree_id"
|
||||||
|
|
||||||
CREATE TABLE "language_servers" (
|
CREATE TABLE "language_servers" (
|
||||||
"project_id" INTEGER NOT NULL REFERENCES projects (id) ON DELETE CASCADE,
|
"project_id" INTEGER NOT NULL REFERENCES projects (id) ON DELETE CASCADE,
|
||||||
"id" INTEGER NOT NULL,
|
"id" INT8 NOT NULL,
|
||||||
"name" VARCHAR NOT NULL,
|
"name" VARCHAR NOT NULL,
|
||||||
PRIMARY KEY(project_id, id)
|
PRIMARY KEY(project_id, id)
|
||||||
);
|
);
|
||||||
|
|
|
@ -1494,17 +1494,21 @@ impl Database {
|
||||||
.insert(&tx)
|
.insert(&tx)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
worktree::Entity::insert_many(worktrees.iter().map(|worktree| worktree::ActiveModel {
|
if !worktrees.is_empty() {
|
||||||
id: ActiveValue::set(worktree.id as i64),
|
worktree::Entity::insert_many(worktrees.iter().map(|worktree| {
|
||||||
project_id: ActiveValue::set(project.id),
|
worktree::ActiveModel {
|
||||||
abs_path: ActiveValue::set(worktree.abs_path.clone()),
|
id: ActiveValue::set(worktree.id as i64),
|
||||||
root_name: ActiveValue::set(worktree.root_name.clone()),
|
project_id: ActiveValue::set(project.id),
|
||||||
visible: ActiveValue::set(worktree.visible),
|
abs_path: ActiveValue::set(worktree.abs_path.clone()),
|
||||||
scan_id: ActiveValue::set(0),
|
root_name: ActiveValue::set(worktree.root_name.clone()),
|
||||||
is_complete: ActiveValue::set(false),
|
visible: ActiveValue::set(worktree.visible),
|
||||||
}))
|
scan_id: ActiveValue::set(0),
|
||||||
.exec(&tx)
|
is_complete: ActiveValue::set(false),
|
||||||
.await?;
|
}
|
||||||
|
}))
|
||||||
|
.exec(&tx)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
|
||||||
project_collaborator::ActiveModel {
|
project_collaborator::ActiveModel {
|
||||||
project_id: ActiveValue::set(project.id),
|
project_id: ActiveValue::set(project.id),
|
||||||
|
@ -1564,17 +1568,27 @@ impl Database {
|
||||||
.await?
|
.await?
|
||||||
.ok_or_else(|| anyhow!("no such project"))?;
|
.ok_or_else(|| anyhow!("no such project"))?;
|
||||||
|
|
||||||
worktree::Entity::insert_many(worktrees.iter().map(|worktree| worktree::ActiveModel {
|
if !worktrees.is_empty() {
|
||||||
id: ActiveValue::set(worktree.id as i64),
|
worktree::Entity::insert_many(worktrees.iter().map(|worktree| {
|
||||||
project_id: ActiveValue::set(project.id),
|
worktree::ActiveModel {
|
||||||
abs_path: ActiveValue::set(worktree.abs_path.clone()),
|
id: ActiveValue::set(worktree.id as i64),
|
||||||
root_name: ActiveValue::set(worktree.root_name.clone()),
|
project_id: ActiveValue::set(project.id),
|
||||||
visible: ActiveValue::set(worktree.visible),
|
abs_path: ActiveValue::set(worktree.abs_path.clone()),
|
||||||
scan_id: ActiveValue::set(0),
|
root_name: ActiveValue::set(worktree.root_name.clone()),
|
||||||
is_complete: ActiveValue::set(false),
|
visible: ActiveValue::set(worktree.visible),
|
||||||
}))
|
scan_id: ActiveValue::set(0),
|
||||||
.exec(&tx)
|
is_complete: ActiveValue::set(false),
|
||||||
.await?;
|
}
|
||||||
|
}))
|
||||||
|
.on_conflict(
|
||||||
|
OnConflict::columns([worktree::Column::ProjectId, worktree::Column::Id])
|
||||||
|
.update_column(worktree::Column::RootName)
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.exec(&tx)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
|
||||||
worktree::Entity::delete_many()
|
worktree::Entity::delete_many()
|
||||||
.filter(
|
.filter(
|
||||||
worktree::Column::ProjectId.eq(project.id).and(
|
worktree::Column::ProjectId.eq(project.id).and(
|
||||||
|
@ -1623,53 +1637,57 @@ impl Database {
|
||||||
.exec(&tx)
|
.exec(&tx)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
worktree_entry::Entity::insert_many(update.updated_entries.iter().map(|entry| {
|
if !update.updated_entries.is_empty() {
|
||||||
let mtime = entry.mtime.clone().unwrap_or_default();
|
worktree_entry::Entity::insert_many(update.updated_entries.iter().map(|entry| {
|
||||||
worktree_entry::ActiveModel {
|
let mtime = entry.mtime.clone().unwrap_or_default();
|
||||||
project_id: ActiveValue::set(project_id),
|
worktree_entry::ActiveModel {
|
||||||
worktree_id: ActiveValue::set(worktree_id),
|
project_id: ActiveValue::set(project_id),
|
||||||
id: ActiveValue::set(entry.id as i64),
|
worktree_id: ActiveValue::set(worktree_id),
|
||||||
is_dir: ActiveValue::set(entry.is_dir),
|
id: ActiveValue::set(entry.id as i64),
|
||||||
path: ActiveValue::set(entry.path.clone()),
|
is_dir: ActiveValue::set(entry.is_dir),
|
||||||
inode: ActiveValue::set(entry.inode as i64),
|
path: ActiveValue::set(entry.path.clone()),
|
||||||
mtime_seconds: ActiveValue::set(mtime.seconds as i64),
|
inode: ActiveValue::set(entry.inode as i64),
|
||||||
mtime_nanos: ActiveValue::set(mtime.nanos as i32),
|
mtime_seconds: ActiveValue::set(mtime.seconds as i64),
|
||||||
is_symlink: ActiveValue::set(entry.is_symlink),
|
mtime_nanos: ActiveValue::set(mtime.nanos as i32),
|
||||||
is_ignored: ActiveValue::set(entry.is_ignored),
|
is_symlink: ActiveValue::set(entry.is_symlink),
|
||||||
}
|
is_ignored: ActiveValue::set(entry.is_ignored),
|
||||||
}))
|
}
|
||||||
.on_conflict(
|
}))
|
||||||
OnConflict::columns([
|
.on_conflict(
|
||||||
worktree_entry::Column::ProjectId,
|
OnConflict::columns([
|
||||||
worktree_entry::Column::WorktreeId,
|
worktree_entry::Column::ProjectId,
|
||||||
worktree_entry::Column::Id,
|
worktree_entry::Column::WorktreeId,
|
||||||
])
|
worktree_entry::Column::Id,
|
||||||
.update_columns([
|
])
|
||||||
worktree_entry::Column::IsDir,
|
.update_columns([
|
||||||
worktree_entry::Column::Path,
|
worktree_entry::Column::IsDir,
|
||||||
worktree_entry::Column::Inode,
|
worktree_entry::Column::Path,
|
||||||
worktree_entry::Column::MtimeSeconds,
|
worktree_entry::Column::Inode,
|
||||||
worktree_entry::Column::MtimeNanos,
|
worktree_entry::Column::MtimeSeconds,
|
||||||
worktree_entry::Column::IsSymlink,
|
worktree_entry::Column::MtimeNanos,
|
||||||
worktree_entry::Column::IsIgnored,
|
worktree_entry::Column::IsSymlink,
|
||||||
])
|
worktree_entry::Column::IsIgnored,
|
||||||
.to_owned(),
|
])
|
||||||
)
|
.to_owned(),
|
||||||
.exec(&tx)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
worktree_entry::Entity::delete_many()
|
|
||||||
.filter(
|
|
||||||
worktree_entry::Column::ProjectId
|
|
||||||
.eq(project_id)
|
|
||||||
.and(worktree_entry::Column::WorktreeId.eq(worktree_id))
|
|
||||||
.and(
|
|
||||||
worktree_entry::Column::Id
|
|
||||||
.is_in(update.removed_entries.iter().map(|id| *id as i64)),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
.exec(&tx)
|
.exec(&tx)
|
||||||
.await?;
|
.await?;
|
||||||
|
}
|
||||||
|
|
||||||
|
if !update.removed_entries.is_empty() {
|
||||||
|
worktree_entry::Entity::delete_many()
|
||||||
|
.filter(
|
||||||
|
worktree_entry::Column::ProjectId
|
||||||
|
.eq(project_id)
|
||||||
|
.and(worktree_entry::Column::WorktreeId.eq(worktree_id))
|
||||||
|
.and(
|
||||||
|
worktree_entry::Column::Id
|
||||||
|
.is_in(update.removed_entries.iter().map(|id| *id as i64)),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.exec(&tx)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
|
||||||
let connection_ids = self.project_guest_connection_ids(project_id, &tx).await?;
|
let connection_ids = self.project_guest_connection_ids(project_id, &tx).await?;
|
||||||
self.commit_room_transaction(room_id, tx, connection_ids)
|
self.commit_room_transaction(room_id, tx, connection_ids)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue