Skip to content

Database hardening #9

Description

@rockett-m

I'd limit input size for a user's name and email, and ensure they exist here:

CREATE TABLE IF NOT EXISTS interests (
id SERIAL PRIMARY KEY,
name TEXT,
email TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE IF NOT EXISTS interests (
  id SERIAL PRIMARY KEY,
  name VARCHAR(50) NOT NULL,
  email VARCHAR(50) NOT NULL,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

And here limit the title size and enforce uniqueness. Also make sure the date exists (optional).

CREATE TABLE IF NOT EXISTS stories (
id SERIAL PRIMARY KEY,
title TEXT,
content TEXT,
date DATE,
comments TEXT,
interest_id INTEGER REFERENCES interests(id),
embedding vector(1536)
);

CREATE TABLE IF NOT EXISTS stories (
  id SERIAL PRIMARY KEY,
  title VARCHAR(1000) NOT NULL UNIQUE,
  content TEXT,
  date DATE NOT NULL,
  comments TEXT,
  interest_id INTEGER REFERENCES interests(id),
  embedding vector(1536)
);

DATE could be changed to DATETIME type but that would involve a wider range of project changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions