Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create index concurrently on topic column in library_item table #4078

Merged
merged 8 commits into from
Jun 19, 2024

Conversation

sywhb
Copy link
Contributor

@sywhb sywhb commented Jun 18, 2024

No description provided.

Copy link

vercel bot commented Jun 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
omnivore-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 19, 2024 4:01am
omnivore-prod ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 19, 2024 4:01am

Copy link

github-actions bot commented Jun 19, 2024

Squawk Report

🚒 8 violations across 1 file(s)


packages/db/migrations/0177.do.public_item.sql

-- Type: DO
-- Name: public_item
-- Description: Create a table for public items

BEGIN;

CREATE TABLE omnivore.public_item_source (
    id uuid PRIMARY KEY DEFAULT uuid_generate_v1mc(),
    name TEXT NOT NULL,
    type TEXT NOT NULL, -- public feeds, newsletters, or user recommended
    topics TEXT[],
    icon TEXT,
    url TEXT,
    language_codes TEXT[],
    approved BOOLEAN NOT NULL DEFAULT FALSE,
    created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
);

CREATE TRIGGER update_public_item_source_modtime BEFORE UPDATE ON omnivore.public_item_source FOR EACH ROW EXECUTE PROCEDURE update_updated_at_column();
GRANT SELECT ON omnivore.public_item_source TO omnivore_user;


CREATE TABLE omnivore.public_item (
	id uuid PRIMARY KEY DEFAULT uuid_generate_v1mc(),
    source_id uuid NOT NULL REFERENCES omnivore.public_item_source(id) ON DELETE CASCADE,
    site_icon TEXT,
    type TEXT NOT NULL, -- public feeds, newsletters, or user recommended
    title TEXT NOT NULL,
    url TEXT NOT NULL,
    topic TEXT,
    approved BOOLEAN NOT NULL DEFAULT FALSE,
    thumbnail TEXT,
    preview_content TEXT,
    language_code TEXT,
    author TEXT,
    dir TEXT,
    published_at timestamptz,
    word_count INT,
    site_name TEXT,
    created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
);

CREATE TRIGGER update_public_item_modtime BEFORE UPDATE ON omnivore.public_item FOR EACH ROW EXECUTE PROCEDURE update_updated_at_column();
GRANT SELECT ON omnivore.public_item TO omnivore_user;


CREATE TABLE omnivore.public_item_stats (
    id uuid PRIMARY KEY DEFAULT uuid_generate_v1mc(),
    public_item_id uuid NOT NULL REFERENCES omnivore.public_item(id) ON DELETE CASCADE,
    save_count INT NOT NULL DEFAULT 0,
    like_count INT NOT NULL DEFAULT 0,
    broadcast_count INT NOT NULL DEFAULT 0,
    created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
);

CREATE INDEX public_item_stats_public_item_id_idx ON omnivore.public_item_stats(public_item_id);
CREATE TRIGGER update_public_item_stats_modtime BEFORE UPDATE ON omnivore.public_item_stats FOR EACH ROW EXECUTE PROCEDURE update_updated_at_column();
GRANT SELECT ON omnivore.public_item_stats TO omnivore_user;


CREATE TABLE omnivore.public_item_interactions (
	id uuid PRIMARY KEY DEFAULT uuid_generate_v1mc(),
    user_id uuid NOT NULL REFERENCES omnivore.user(id) ON DELETE CASCADE,
    public_item_id uuid NOT NULL REFERENCES omnivore.public_item(id) ON DELETE CASCADE,
    saved_at TIMESTAMPTZ,
    liked_at TIMESTAMPTZ,
    broadcasted_at TIMESTAMPTZ,
    seen_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
    digested_at TIMESTAMPTZ,
    created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
);

CREATE INDEX public_item_interaction_user_id_idx ON omnivore.public_item_interactions(user_id);
CREATE INDEX public_item_interaction_public_item_id_idx ON omnivore.public_item_interactions(public_item_id);
CREATE TRIGGER update_public_item_interactions_modtime BEFORE UPDATE ON omnivore.public_item_interactions FOR EACH ROW EXECUTE PROCEDURE update_updated_at_column();
GRANT SELECT, INSERT, UPDATE ON omnivore.public_item_interactions TO omnivore_user;

CREATE EXTENSION IF NOT EXISTS LTREE;

ALTER TABLE omnivore.library_item 
    ADD COLUMN seen_at TIMESTAMPTZ,
    ADD COLUMN digested_at TIMESTAMPTZ,
    ADD COLUMN topic LTREE,
    ADD COLUMN score FLOAT;

COMMIT;

🚒 Rule Violations (8)

packages/db/migrations/0177.do.public_item.sql:22:3: warning: prefer-big-int

  22 | CREATE TABLE omnivore.public_item (
  23 | 	id uuid PRIMARY KEY DEFAULT uuid_generate_v1mc(),
  24 |     source_id uuid NOT NULL REFERENCES omnivore.public_item_source(id) ON DELETE CASCADE,
  25 |     site_icon TEXT,
  26 |     type TEXT NOT NULL, -- public feeds, newsletters, or user recommended
  27 |     title TEXT NOT NULL,
  28 |     url TEXT NOT NULL,
  29 |     topic TEXT,
  30 |     approved BOOLEAN NOT NULL DEFAULT FALSE,
  31 |     thumbnail TEXT,
  32 |     preview_content TEXT,
  33 |     language_code TEXT,
  34 |     author TEXT,
  35 |     dir TEXT,
  36 |     published_at timestamptz,
  37 |     word_count INT,
  38 |     site_name TEXT,
  39 |     created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
  40 |     updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
  41 | );

  note: Hitting the max 32 bit integer is possible and may break your application.
  help: Use 64bit integer values instead to prevent hitting this limit.

packages/db/migrations/0177.do.public_item.sql:22:3: warning: prefer-bigint-over-int

  22 | CREATE TABLE omnivore.public_item (
  23 | 	id uuid PRIMARY KEY DEFAULT uuid_generate_v1mc(),
  24 |     source_id uuid NOT NULL REFERENCES omnivore.public_item_source(id) ON DELETE CASCADE,
  25 |     site_icon TEXT,
  26 |     type TEXT NOT NULL, -- public feeds, newsletters, or user recommended
  27 |     title TEXT NOT NULL,
  28 |     url TEXT NOT NULL,
  29 |     topic TEXT,
  30 |     approved BOOLEAN NOT NULL DEFAULT FALSE,
  31 |     thumbnail TEXT,
  32 |     preview_content TEXT,
  33 |     language_code TEXT,
  34 |     author TEXT,
  35 |     dir TEXT,
  36 |     published_at timestamptz,
  37 |     word_count INT,
  38 |     site_name TEXT,
  39 |     created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
  40 |     updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
  41 | );

  note: Hitting the max 32 bit integer is possible and may break your application.
  help: Use 64bit integer values instead to prevent hitting this limit.

packages/db/migrations/0177.do.public_item.sql:47:3: warning: prefer-big-int

  47 | CREATE TABLE omnivore.public_item_stats (
  48 |     id uuid PRIMARY KEY DEFAULT uuid_generate_v1mc(),
  49 |     public_item_id uuid NOT NULL REFERENCES omnivore.public_item(id) ON DELETE CASCADE,
  50 |     save_count INT NOT NULL DEFAULT 0,
  51 |     like_count INT NOT NULL DEFAULT 0,
  52 |     broadcast_count INT NOT NULL DEFAULT 0,
  53 |     created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
  54 |     updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
  55 | );

  note: Hitting the max 32 bit integer is possible and may break your application.
  help: Use 64bit integer values instead to prevent hitting this limit.

packages/db/migrations/0177.do.public_item.sql:47:3: warning: prefer-big-int

  47 | CREATE TABLE omnivore.public_item_stats (
  48 |     id uuid PRIMARY KEY DEFAULT uuid_generate_v1mc(),
  49 |     public_item_id uuid NOT NULL REFERENCES omnivore.public_item(id) ON DELETE CASCADE,
  50 |     save_count INT NOT NULL DEFAULT 0,
  51 |     like_count INT NOT NULL DEFAULT 0,
  52 |     broadcast_count INT NOT NULL DEFAULT 0,
  53 |     created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
  54 |     updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
  55 | );

  note: Hitting the max 32 bit integer is possible and may break your application.
  help: Use 64bit integer values instead to prevent hitting this limit.

packages/db/migrations/0177.do.public_item.sql:47:3: warning: prefer-big-int

  47 | CREATE TABLE omnivore.public_item_stats (
  48 |     id uuid PRIMARY KEY DEFAULT uuid_generate_v1mc(),
  49 |     public_item_id uuid NOT NULL REFERENCES omnivore.public_item(id) ON DELETE CASCADE,
  50 |     save_count INT NOT NULL DEFAULT 0,
  51 |     like_count INT NOT NULL DEFAULT 0,
  52 |     broadcast_count INT NOT NULL DEFAULT 0,
  53 |     created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
  54 |     updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
  55 | );

  note: Hitting the max 32 bit integer is possible and may break your application.
  help: Use 64bit integer values instead to prevent hitting this limit.

packages/db/migrations/0177.do.public_item.sql:47:3: warning: prefer-bigint-over-int

  47 | CREATE TABLE omnivore.public_item_stats (
  48 |     id uuid PRIMARY KEY DEFAULT uuid_generate_v1mc(),
  49 |     public_item_id uuid NOT NULL REFERENCES omnivore.public_item(id) ON DELETE CASCADE,
  50 |     save_count INT NOT NULL DEFAULT 0,
  51 |     like_count INT NOT NULL DEFAULT 0,
  52 |     broadcast_count INT NOT NULL DEFAULT 0,
  53 |     created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
  54 |     updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
  55 | );

  note: Hitting the max 32 bit integer is possible and may break your application.
  help: Use 64bit integer values instead to prevent hitting this limit.

packages/db/migrations/0177.do.public_item.sql:47:3: warning: prefer-bigint-over-int

  47 | CREATE TABLE omnivore.public_item_stats (
  48 |     id uuid PRIMARY KEY DEFAULT uuid_generate_v1mc(),
  49 |     public_item_id uuid NOT NULL REFERENCES omnivore.public_item(id) ON DELETE CASCADE,
  50 |     save_count INT NOT NULL DEFAULT 0,
  51 |     like_count INT NOT NULL DEFAULT 0,
  52 |     broadcast_count INT NOT NULL DEFAULT 0,
  53 |     created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
  54 |     updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
  55 | );

  note: Hitting the max 32 bit integer is possible and may break your application.
  help: Use 64bit integer values instead to prevent hitting this limit.

packages/db/migrations/0177.do.public_item.sql:47:3: warning: prefer-bigint-over-int

  47 | CREATE TABLE omnivore.public_item_stats (
  48 |     id uuid PRIMARY KEY DEFAULT uuid_generate_v1mc(),
  49 |     public_item_id uuid NOT NULL REFERENCES omnivore.public_item(id) ON DELETE CASCADE,
  50 |     save_count INT NOT NULL DEFAULT 0,
  51 |     like_count INT NOT NULL DEFAULT 0,
  52 |     broadcast_count INT NOT NULL DEFAULT 0,
  53 |     created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
  54 |     updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
  55 | );

  note: Hitting the max 32 bit integer is possible and may break your application.
  help: Use 64bit integer values instead to prevent hitting this limit.

📚 More info on rules

⚡️ Powered by Squawk (1.1.1), a linter for PostgreSQL, focused on migrations

@sywhb sywhb merged commit aaa88be into main Jun 19, 2024
7 checks passed
@sywhb sywhb deleted the fix/create-index-on-topic-concurrently branch June 19, 2024 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants