Salon Appointment Scheduler Database

While working on completing the salon appointment scheduler database, I encountered a roadblock with subtasks 18 to 20. Despite my efforts, the code wasn’t executing as expected. Here’s a snippet of my previous code:

CREATE DATABASE salon;
\C salon
CREATE TABLE customers(
  customer_id SERIAL PRIMARY KEY,
  name VARCHAR(30) UNIQUE NOT NULL,
  phone VARCHAR(30) UNIQUE
);

CREATE TABLE services(
  service_id SERIAL PRIMARY KEY,
  name VARCHAR(30) UNIQUE NOT NULL
);

CREATE TABLE appointments(
  appointment_id SERIAL PRIMARY KEY,
  customer_id INT REFERENCES customers(customer_id),
  service_id INT REFERENCES services(service_id),
  time VARCHAR(7)
);

INSERT INTO services(name,price) VALUES ('cut', 35),
    ('color', 125),
    ('perm', 100),
    ('style', 65),
    ('trim', 20),
    ('massage', 90);

After extensive troubleshooting, I realized that the issue lied with the test files trying to add time values longer than the specified length of 7 characters, such as “FAKETIME”. To resolve this, I made a simple fix in the database structure:

ALTER TABLE appointments ALTER COLUMN time SET DATA TYPE VARCHAR(20);

And just like that, all the tests passed smoothly. Problem solved!

1 Like

This post is for people who are stuck and searching to check they might have the same issue