Skip to content

Commit

Permalink
Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
burkkyy committed Jul 8, 2024
1 parent cdbd1bf commit 7c89f68
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions api/src/db/migrations/2024.06.07T00.36.14.clean-user-group-names.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import type { Migration } from "@/db/umzug";
import { QueryTypes } from "sequelize";
import type { Migration } from "@/db/umzug"
import { QueryTypes } from "sequelize"

export const up: Migration = async ({ context: queryInterface }) => {
const rows: { id: number, name: string }[] = await queryInterface.sequelize.query(
'SELECT id, name FROM user_groups',
const rows: { id: number; name: string }[] = await queryInterface.sequelize.query(
"SELECT id, name FROM user_groups",
{
type: QueryTypes.SELECT,
}
);
)

for (const row of rows) {
const trimmedName = row.name.trim().replace(/\s+/g, " ");
const trimmedName = row.name.trim().replace(/\s+/g, " ")
await queryInterface.sequelize.query(
'UPDATE user_groups SET name = :trimmedName WHERE id = :userId',
"UPDATE user_groups SET name = :trimmedName WHERE id = :userId",
{
replacements: { trimmedName, userId: row.id },
}
);
)
}
};
}

export const down: Migration = async () => {
// no-op
};
}

0 comments on commit 7c89f68

Please sign in to comment.