fix: bug fixes
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
-- Create a temp table
|
||||
CREATE TABLE torrent_tmp (
|
||||
infohash text NOT NULL,
|
||||
name text NOT NULL,
|
||||
size_bytes bigint NOT NULL,
|
||||
created_unix bigint NOT NULL,
|
||||
seeders integer NOT NULL,
|
||||
leechers integer NOT NULL,
|
||||
completed integer NOT NULL,
|
||||
scraped_date bigint NOT NULL,
|
||||
published bigint NOT NULL
|
||||
);
|
||||
|
||||
-- Copy from csv
|
||||
COPY torrent_tmp
|
||||
FROM
|
||||
'../torrents.csv' WITH (
|
||||
FORMAT csv,
|
||||
HEADER);
|
||||
|
||||
-- default sort by seeders
|
||||
CREATE TABLE torrent AS
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
torrent_tmp
|
||||
ORDER BY
|
||||
seeders DESC;
|
||||
|
||||
-- Add the identity column
|
||||
ALTER TABLE torrent
|
||||
ADD COLUMN id int GENERATED ALWAYS AS IDENTITY,
|
||||
ADD COLUMN name_search tsvector GENERATED ALWAYS AS (to_tsvector('english', name)) STORED;
|
||||
|
||||
CREATE INDEX idx_name ON torrent USING gin (name_search);
|
||||
|
||||
DROP TABLE torrent_tmp;
|
||||
|
||||
Reference in New Issue
Block a user