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,7 +1494,9 @@ impl Database {
|
||||||
.insert(&tx)
|
.insert(&tx)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
worktree::Entity::insert_many(worktrees.iter().map(|worktree| worktree::ActiveModel {
|
if !worktrees.is_empty() {
|
||||||
|
worktree::Entity::insert_many(worktrees.iter().map(|worktree| {
|
||||||
|
worktree::ActiveModel {
|
||||||
id: ActiveValue::set(worktree.id as i64),
|
id: ActiveValue::set(worktree.id as i64),
|
||||||
project_id: ActiveValue::set(project.id),
|
project_id: ActiveValue::set(project.id),
|
||||||
abs_path: ActiveValue::set(worktree.abs_path.clone()),
|
abs_path: ActiveValue::set(worktree.abs_path.clone()),
|
||||||
|
|
@ -1502,9 +1504,11 @@ impl Database {
|
||||||
visible: ActiveValue::set(worktree.visible),
|
visible: ActiveValue::set(worktree.visible),
|
||||||
scan_id: ActiveValue::set(0),
|
scan_id: ActiveValue::set(0),
|
||||||
is_complete: ActiveValue::set(false),
|
is_complete: ActiveValue::set(false),
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
.exec(&tx)
|
.exec(&tx)
|
||||||
.await?;
|
.await?;
|
||||||
|
}
|
||||||
|
|
||||||
project_collaborator::ActiveModel {
|
project_collaborator::ActiveModel {
|
||||||
project_id: ActiveValue::set(project.id),
|
project_id: ActiveValue::set(project.id),
|
||||||
|
|
@ -1564,7 +1568,9 @@ 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() {
|
||||||
|
worktree::Entity::insert_many(worktrees.iter().map(|worktree| {
|
||||||
|
worktree::ActiveModel {
|
||||||
id: ActiveValue::set(worktree.id as i64),
|
id: ActiveValue::set(worktree.id as i64),
|
||||||
project_id: ActiveValue::set(project.id),
|
project_id: ActiveValue::set(project.id),
|
||||||
abs_path: ActiveValue::set(worktree.abs_path.clone()),
|
abs_path: ActiveValue::set(worktree.abs_path.clone()),
|
||||||
|
|
@ -1572,9 +1578,17 @@ impl Database {
|
||||||
visible: ActiveValue::set(worktree.visible),
|
visible: ActiveValue::set(worktree.visible),
|
||||||
scan_id: ActiveValue::set(0),
|
scan_id: ActiveValue::set(0),
|
||||||
is_complete: ActiveValue::set(false),
|
is_complete: ActiveValue::set(false),
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
|
.on_conflict(
|
||||||
|
OnConflict::columns([worktree::Column::ProjectId, worktree::Column::Id])
|
||||||
|
.update_column(worktree::Column::RootName)
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
.exec(&tx)
|
.exec(&tx)
|
||||||
.await?;
|
.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,6 +1637,7 @@ impl Database {
|
||||||
.exec(&tx)
|
.exec(&tx)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
if !update.updated_entries.is_empty() {
|
||||||
worktree_entry::Entity::insert_many(update.updated_entries.iter().map(|entry| {
|
worktree_entry::Entity::insert_many(update.updated_entries.iter().map(|entry| {
|
||||||
let mtime = entry.mtime.clone().unwrap_or_default();
|
let mtime = entry.mtime.clone().unwrap_or_default();
|
||||||
worktree_entry::ActiveModel {
|
worktree_entry::ActiveModel {
|
||||||
|
|
@ -1657,7 +1672,9 @@ impl Database {
|
||||||
)
|
)
|
||||||
.exec(&tx)
|
.exec(&tx)
|
||||||
.await?;
|
.await?;
|
||||||
|
}
|
||||||
|
|
||||||
|
if !update.removed_entries.is_empty() {
|
||||||
worktree_entry::Entity::delete_many()
|
worktree_entry::Entity::delete_many()
|
||||||
.filter(
|
.filter(
|
||||||
worktree_entry::Column::ProjectId
|
worktree_entry::Column::ProjectId
|
||||||
|
|
@ -1670,6 +1687,7 @@ impl Database {
|
||||||
)
|
)
|
||||||
.exec(&tx)
|
.exec(&tx)
|
||||||
.await?;
|
.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