CREATE EXTENSION IF NOT EXISTS "pgcrypto";

CREATE TABLE places (
	id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
	name VARCHAR(255),
	latitude DOUBLE PRECISION,
	longitude DOUBLE PRECISION,
	address VARCHAR(1023),
  location_type VARCHAR(255) CHECK (location_type IN ('mosque', 'other', 'outdoor_space', 'multi_faith_room')),
	womens_space BOOLEAN,
	wudu BOOLEAN,
	website_url VARCHAR(2047) DEFAULT NULL,
	notes VARCHAR(4095)
);

CREATE TABLE users (
	id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
	username VARCHAR(255),
	hashedpass VARCHAR(255)
);

CREATE TABLE reviews (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
	reviewer UUID REFERENCES users(id),
	place UUID REFERENCES places(id),
  quiet INT NOT NULL,
  clean INT NOT NULL,
	clean_wudu INT NOT NULL,
  private INT NOT NULL,
	child_friendly INT NOT NULL,
	safe INT NOT NULL,
	notes VARCHAR(4095) DEFAULT NULL
);

CREATE TABLE place_images (
	id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
	place_id UUID REFERENCES places(id),
	image_url VARCHAR(2047),
	notes VARCHAR(4095)
)
