35354-vm/db/migrations/003_create_loans_table.sql
Flatlogic Bot 2332ec6934 1.0
2025-10-30 14:24:12 +00:00

11 lines
350 B
SQL

CREATE TABLE IF NOT EXISTS `loans` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`book_id` INT NOT NULL,
`user_id` INT NOT NULL,
`loan_date` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`due_date` TIMESTAMP NOT NULL,
`return_date` TIMESTAMP NULL,
FOREIGN KEY (`book_id`) REFERENCES `books`(`id`),
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`)
);