generate script fix

This commit is contained in:
2026-05-17 21:21:43 +02:00
parent e64288694b
commit 6c70628616

View File

@@ -19,6 +19,7 @@ var rng = new Random(SEED);
await using var conn = new MySqlConnection(DSN); await using var conn = new MySqlConnection(DSN);
await conn.OpenAsync(); await conn.OpenAsync();
Console.WriteLine("Connected."); Console.WriteLine("Connected.");
await new MySqlCommand("SET foreign_key_checks=0, unique_checks=0", conn).ExecuteNonQueryAsync();
async Task Exec(string sql) async Task Exec(string sql)
{ {
@@ -480,9 +481,8 @@ while (bookingsDone < BOOKING_COUNT)
bookingRows.Add($"({guestId},{hotelId},{D(checkin)},{D(checkout)},{S(status)},{DT(created)})"); bookingRows.Add($"({guestId},{hotelId},{D(checkin)},{D(checkout)},{S(status)},{DT(created)})");
} }
// Insert bookings and get the first inserted ID
long firstId = await ExecScalar("SELECT AUTO_INCREMENT FROM information_schema.tables WHERE table_schema='hotel_reservations' AND table_name='booking'");
await Exec($"INSERT INTO booking (guest_id, hotel_id, date_from, date_to, status, created_at) VALUES {string.Join(',', bookingRows)}"); await Exec($"INSERT INTO booking (guest_id, hotel_id, date_from, date_to, status, created_at) VALUES {string.Join(',', bookingRows)}");
long firstId = await ExecScalar("SELECT LAST_INSERT_ID()");
// Re-derive checkin/nights from the same rng sequence is impossible after the fact, // Re-derive checkin/nights from the same rng sequence is impossible after the fact,
// so re-parse from inserted rows to build room_bookings // so re-parse from inserted rows to build room_bookings