CREATE EXTENSION IF NOT EXISTS vector;

ALTER TABLE media
ADD COLUMN embedding vector(4);


TRUNCATE TABLE "review" RESTART IDENTITY;

DO $$
DECLARE
    user_ids int[] := ARRAY(SELECT UserID FROM "User");
    media_ids int[] := ARRAY(SELECT ContentID FROM "media");
    u_count int := cardinality(user_ids);
    m_count int := cardinality(media_ids);
BEGIN
    INSERT INTO "review" (Comment, ReviewDate, UserUserID, ContentContentID)
    SELECT
      (ARRAY[
        'Absolutely amazing, one of the best!',
        'Great story, highly recommend.',
        'A bit slow at the start but gets better.',
        'Masterpiece of cinema.',
        'Not what I expected but still enjoyable.',
        'Incredible performances all around.',
        'The ending blew my mind.',
        'Would watch again without hesitation.',
        'Overrated in my opinion.',
        'A classic that stands the test of time.',
        'Great cinematography and direction.',
        'The plot had some holes but overall good.',
        'One of the best series ever made.',
        'Keeps you on the edge of your seat.',
        'The writing is absolutely top-notch.',
        'Brilliant acting from start to finish.',
        'A must watch for everyone.',
        'Did not live up to the hype.',
        'Absolutely loved every minute of it.',
        'A cinematic masterpiece.',
        'This man is my worst nightmare. 10/10',
        'No.',
        'The portrayal of toxic relationships is very good.'
      ])[ceil(random() * 23)::int],
      CURRENT_DATE - (random() * 730)::int,
      -- Директно влечење од низата со нов случаен индекс за секој ред
      user_ids[ceil(random() * u_count)::int],
      media_ids[ceil(random() * m_count)::int]
    FROM
      generate_series(1, 10000000) AS gs;
END $$;