style: apply Prettier formatting across codebase

Apply consistent code formatting using Prettier to improve code readability
and maintain style consistency throughout the project.

Co-Authored-By: Claude (glm-5) <noreply@anthropic.com>
This commit is contained in:
Misaka_Company
2026-03-04 14:24:16 +08:00
parent 88c8c256e2
commit c61776a1ff
6 changed files with 115 additions and 107 deletions

View File

@@ -4,7 +4,7 @@
* This script modifies the ID column to be AUTO_INCREMENT while preserving data
*/
const mysql = require('mysql2/promise');
const mysql = require('mysql2/promise')
async function main() {
const config = {
@@ -13,17 +13,17 @@ async function main() {
user: 'remote_user',
password: '3.1415926Beeke',
database: 'BLD_DB'
};
}
let connection;
let connection
try {
console.log('Connecting to MySQL...');
connection = await mysql.createConnection(config);
console.log('Connected successfully!\n');
console.log('Connecting to MySQL...')
connection = await mysql.createConnection(config)
console.log('Connected successfully!\n')
// Step 1: Check current table structure
console.log('=== Step 1: Current table structure ===');
console.log('=== Step 1: Current table structure ===')
const [columns] = await connection.execute(`
SELECT
COLUMN_NAME,
@@ -39,40 +39,38 @@ async function main() {
AND TABLE_SCHEMA = DATABASE()
ORDER BY
ORDINAL_POSITION
`);
console.table(columns);
`)
console.table(columns)
// Step 2: Count records before modification
console.log('\n=== Step 2: Record count before modification ===');
console.log('\n=== Step 2: Record count before modification ===')
const [countBefore] = await connection.execute(
'SELECT COUNT(*) AS total FROM dbo_MaterialsTypeToBeDeleted'
);
console.log(`Total records: ${countBefore[0].total}`);
)
console.log(`Total records: ${countBefore[0].total}`)
// Step 3: Show sample data
console.log('\n=== Step 3: Sample data ===');
const [sample] = await connection.execute(
'SELECT * FROM dbo_MaterialsTypeToBeDeleted LIMIT 5'
);
console.table(sample);
console.log('\n=== Step 3: Sample data ===')
const [sample] = await connection.execute('SELECT * FROM dbo_MaterialsTypeToBeDeleted LIMIT 5')
console.table(sample)
// Step 4: Check if ID is already AUTO_INCREMENT
const idColumn = columns.find((col) => col.COLUMN_NAME === 'ID');
const idColumn = columns.find((col) => col.COLUMN_NAME === 'ID')
if (idColumn && idColumn.EXTRA.includes('auto_increment')) {
console.log('\n=== ID is already AUTO_INCREMENT! No modification needed. ===');
return;
console.log('\n=== ID is already AUTO_INCREMENT! No modification needed. ===')
return
}
// Step 5: Modify the ID column
console.log('\n=== Step 4: Modifying ID column to AUTO_INCREMENT ===');
console.log('\n=== Step 4: Modifying ID column to AUTO_INCREMENT ===')
await connection.execute(`
ALTER TABLE dbo_MaterialsTypeToBeDeleted
MODIFY COLUMN ID INT NOT NULL AUTO_INCREMENT
`);
console.log('Modification completed successfully!\n');
`)
console.log('Modification completed successfully!\n')
// Step 6: Verify the change
console.log('=== Step 5: Verify modification ===');
console.log('=== Step 5: Verify modification ===')
const [columnsAfter] = await connection.execute(`
SELECT
COLUMN_NAME,
@@ -86,32 +84,32 @@ async function main() {
TABLE_NAME = 'dbo_MaterialsTypeToBeDeleted'
AND TABLE_SCHEMA = DATABASE()
AND COLUMN_NAME = 'ID'
`);
console.table(columnsAfter);
`)
console.table(columnsAfter)
// Step 7: Verify data is still intact
console.log('\n=== Step 6: Verify data integrity ===');
console.log('\n=== Step 6: Verify data integrity ===')
const [countAfter] = await connection.execute(
'SELECT COUNT(*) AS total FROM dbo_MaterialsTypeToBeDeleted'
);
console.log(`Total records after modification: ${countAfter[0].total}`);
)
console.log(`Total records after modification: ${countAfter[0].total}`)
if (countBefore[0].total === countAfter[0].total) {
console.log('\n✅ SUCCESS: All data preserved, AUTO_INCREMENT added to ID column!');
console.log('\n✅ SUCCESS: All data preserved, AUTO_INCREMENT added to ID column!')
} else {
console.log('\n⚠ WARNING: Record count changed! Please check data.');
console.log('\n⚠ WARNING: Record count changed! Please check data.')
}
} catch (error) {
console.error('\n❌ Error:', error.message);
console.error('\n❌ Error:', error.message)
if (error.code) {
console.error('Error code:', error.code);
console.error('Error code:', error.code)
}
} finally {
if (connection) {
await connection.end();
console.log('\nConnection closed.');
await connection.end()
console.log('\nConnection closed.')
}
}
}
main();
main()