| 12345678910111213141516171819202122 |
- import db
- def migrate():
- print("Starting migration: creating email_verification_tokens table...")
- query = """
- CREATE TABLE IF NOT EXISTS email_verification_tokens (
- id INT AUTO_INCREMENT PRIMARY KEY,
- user_id INT NOT NULL,
- token VARCHAR(255) NOT NULL UNIQUE,
- expires_at TIMESTAMP NOT NULL,
- created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
- """
- try:
- db.execute_commit(query)
- print("SUCCESS: Table 'email_verification_tokens' created successfully (or already exists).")
- except Exception as e:
- print(f"ERROR creating table: {e}")
- if __name__ == "__main__":
- migrate()
|