23 lines
699 B
JavaScript
23 lines
699 B
JavaScript
import mysql from "mysql2/promise";
|
|
import "dotenv/config";
|
|
|
|
const run = async () => {
|
|
const pool = mysql.createPool({
|
|
host: process.env.DB_HOST || "localhost",
|
|
user: process.env.DB_USER || "root",
|
|
password: process.env.DB_PASSWORD,
|
|
database: process.env.DB_NAME || "roadrentals"
|
|
});
|
|
|
|
try {
|
|
console.log("Renaming column 'phone' to 'mobile_number'...");
|
|
await pool.execute("ALTER TABLE User CHANGE COLUMN phone mobile_number VARCHAR(255) NOT NULL");
|
|
console.log("Column successfully renamed!");
|
|
} catch (e) {
|
|
console.error("Error modifying table:", e.message);
|
|
} finally {
|
|
await pool.end();
|
|
}
|
|
};
|
|
|
|
run();
|