move to monorepo dir

This commit is contained in:
Jai A
2024-10-16 14:11:42 -07:00
parent ff7975773e
commit e3a3379615
756 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,102 @@
CREATE TABLE users (
-- TODO
id bigint PRIMARY KEY
);
CREATE TABLE game_versions (
id serial PRIMARY KEY,
version varchar(255) NOT NULL
);
CREATE TABLE loaders (
id serial PRIMARY KEY,
loader varchar(255) NOT NULL
);
CREATE TABLE teams (
id bigint PRIMARY KEY
);
CREATE TABLE release_channel (
id serial PRIMARY KEY,
channel varchar(255)
);
CREATE TABLE mods (
id bigint PRIMARY KEY,
team_id bigint REFERENCES teams NOT NULL,
title varchar(255) NOT NULL,
description varchar(2048) NOT NULL,
body_url varchar(2048) NOT NULL,
published timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL,
downloads integer NOT NULL DEFAULT 0,
icon_url varchar(2048) NULL,
issues_url varchar(2048) NULL,
source_url varchar(2048) NULL,
wiki_url varchar(2048) NULL
);
CREATE TABLE versions (
id bigint PRIMARY KEY,
mod_id bigint REFERENCES mods,
name varchar(255) NOT NULL,
version_number varchar(255) NOT NULL,
changelog_url varchar(255) NULL,
date_published timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL,
downloads integer NOT NULL DEFAULT 0,
release_channel int REFERENCES release_channel ON UPDATE CASCADE NOT NULL
);
CREATE TABLE loaders_versions (
loader_id int REFERENCES loaders ON UPDATE CASCADE NOT NULL,
version_id bigint REFERENCES versions ON UPDATE CASCADE NOT NULL,
PRIMARY KEY (loader_id, version_id)
);
CREATE TABLE game_versions_versions (
game_version_id integer REFERENCES game_versions ON UPDATE CASCADE NOT NULL,
joining_version_id bigint REFERENCES versions ON UPDATE CASCADE NOT NULL,
PRIMARY KEY (game_version_id, joining_version_id)
);
CREATE TABLE files (
id bigint PRIMARY KEY,
version_id bigint REFERENCES versions NOT NULL,
url varchar(2048) NOT NULL
);
CREATE TABLE hashes (
file_id bigint REFERENCES files NOT NULL,
algorithm varchar(255) NOT NULL,
hash bytea NOT NULL,
PRIMARY KEY (file_id, algorithm)
);
CREATE TABLE dependencies (
id serial PRIMARY KEY,
dependent_id bigint REFERENCES versions ON UPDATE CASCADE NOT NULL,
dependency_id bigint REFERENCES versions ON UPDATE CASCADE NOT NULL,
CONSTRAINT valid_dependency CHECK (dependent_id <> dependency_id) -- No dependency on yourself
);
CREATE TABLE team_members (
id bigint PRIMARY KEY,
team_id bigint REFERENCES teams NOT NULL,
user_id bigint REFERENCES users NOT NULL,
member_name varchar(255) NOT NULL,
role varchar(255) NOT NULL
);
CREATE TABLE categories (
id serial PRIMARY KEY,
category varchar(255) UNIQUE
);
CREATE TABLE mods_categories (
joining_mod_id bigint REFERENCES mods ON UPDATE CASCADE NOT NULL,
joining_category_id int REFERENCES categories ON UPDATE CASCADE NOT NULL,
PRIMARY KEY (joining_mod_id, joining_category_id)
);

View File

@@ -0,0 +1,3 @@
-- Add migration script here
ALTER TABLE categories
ALTER COLUMN category SET NOT NULL;

View File

@@ -0,0 +1,7 @@
-- Add migration script here
INSERT INTO release_channel (channel) VALUES ('release');
INSERT INTO release_channel (channel) VALUES ('release-hidden');
INSERT INTO release_channel (channel) VALUES ('beta');
INSERT INTO release_channel (channel) VALUES ('beta-hidden');
INSERT INTO release_channel (channel) VALUES ('alpha');
INSERT INTO release_channel (channel) VALUES ('alpha-hidden');

View File

@@ -0,0 +1,2 @@
-- Add migration script here
ALTER TABLE release_channel RENAME TO release_channels

View File

@@ -0,0 +1,3 @@
-- Add migration script here
ALTER TABLE files
ADD filename varchar(2048) NOT NULL;

View File

@@ -0,0 +1,6 @@
-- Add migration script here
ALTER TABLE versions
ALTER COLUMN mod_id SET NOT NULL;
ALTER TABLE release_channels
ALTER COLUMN channel SET NOT NULL;

View File

@@ -0,0 +1,5 @@
ALTER TABLE game_versions
ADD UNIQUE(version);
ALTER TABLE loaders
ADD UNIQUE(loader);

View File

@@ -0,0 +1,4 @@
CREATE TABLE states (
id bigint PRIMARY KEY,
url varchar(500)
);

View File

@@ -0,0 +1,4 @@
-- Add migration script here
ALTER TABLE states
ADD COLUMN expires timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP + interval '1 hour';

View File

@@ -0,0 +1,3 @@
-- Add migration script here
ALTER TABLE states
ALTER COLUMN url SET NOT NULL;

View File

@@ -0,0 +1,8 @@
ALTER TABLE users
ADD COLUMN github_id bigint NOT NULL default 0,
ADD COLUMN username varchar(255) NOT NULL default 'username',
ADD COLUMN name varchar(255) NOT NULL default 'John Doe',
ADD COLUMN email varchar(255) NULL default 'johndoe@modrinth.com',
ADD COLUMN avatar_url varchar(500) NOT NULL default '...',
ADD COLUMN bio varchar(160) NOT NULL default 'I make mods!',
ADD COLUMN created timestamptz default CURRENT_TIMESTAMP NOT NULL

View File

@@ -0,0 +1,3 @@
-- Add migration script here
ALTER TABLE users
ADD COLUMN role varchar(50) NOT NULL default 'developer'

View File

@@ -0,0 +1,3 @@
-- Add migration script here
ALTER TABLE versions
ADD COLUMN author_id bigint REFERENCES users NOT NULL default 0

View File

@@ -0,0 +1,35 @@
-- Originally:
-- ALTER TABLE users
-- ADD COLUMN github_id bigint NOT NULL default 0,
-- ADD COLUMN username varchar(255) NOT NULL default 'username',
-- ADD COLUMN name varchar(255) NOT NULL default 'John Doe',
-- ADD COLUMN email varchar(255) NULL default 'johndoe@modrinth.com',
-- ADD COLUMN avatar_url varchar(500) NOT NULL default '...',
-- ADD COLUMN bio varchar(160) NOT NULL default 'I make mods!',
-- ADD COLUMN created timestamptz default CURRENT_TIMESTAMP NOT NULL
-- We don't want garbage data when users are created incorrectly;
-- we just want it to fail.
ALTER TABLE users
ALTER COLUMN github_id DROP NOT NULL;
ALTER TABLE users
ALTER COLUMN github_id DROP DEFAULT;
ALTER TABLE users
ALTER COLUMN avatar_url DROP NOT NULL;
ALTER TABLE users
ALTER COLUMN avatar_url DROP DEFAULT;
ALTER TABLE users
ALTER COLUMN username DROP DEFAULT;
ALTER TABLE users
ALTER COLUMN name DROP DEFAULT;
ALTER TABLE users
ALTER COLUMN email DROP DEFAULT;
ALTER TABLE users
ALTER COLUMN bio DROP DEFAULT;
ALTER TABLE users
ALTER COLUMN bio DROP NOT NULL;

View File

@@ -0,0 +1,5 @@
-- Add migration script here
ALTER TABLE users
ALTER COLUMN name DROP NOT NULL;
ALTER TABLE users
ALTER COLUMN name DROP DEFAULT;

View File

@@ -0,0 +1,15 @@
CREATE TABLE statuses (
id serial PRIMARY KEY UNIQUE NOT NULL,
status varchar(64) UNIQUE NOT NULL
);
ALTER TABLE mods
ADD COLUMN status integer REFERENCES statuses NOT NULL;
ALTER TABLE mods
ADD COLUMN updated timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP;
INSERT INTO statuses (status) VALUES ('approved');
INSERT INTO statuses (status) VALUES ('rejected');
INSERT INTO statuses (status) VALUES ('draft');
INSERT INTO statuses (status) VALUES ('unlisted');
INSERT INTO statuses (status) VALUES ('processing');

View File

@@ -0,0 +1,3 @@
ALTER TABLE game_versions
ADD COLUMN type varchar(16) NOT NULL DEFAULT 'other';

View File

@@ -0,0 +1,3 @@
ALTER TABLE game_versions
ADD COLUMN created timestamptz NOT NULL DEFAULT timezone('utc', now());

View File

@@ -0,0 +1,5 @@
-- Add migration script here
ALTER TABLE team_members
ADD COLUMN permissions bigint default 0 NOT NULL;
ALTER TABLE team_members
ADD COLUMN accepted boolean default false NOT NULL;

View File

@@ -0,0 +1,7 @@
-- Add migration script here
DELETE FROM release_channels WHERE channel = 'release-hidden';
DELETE FROM release_channels WHERE channel = 'beta-hidden';
DELETE FROM release_channels WHERE channel = 'alpha-hidden';
ALTER TABLE versions
ADD COLUMN accepted BOOLEAN NOT NULL default FALSE;

View File

@@ -0,0 +1,63 @@
CREATE TABLE donation_platforms (
id serial PRIMARY KEY,
short varchar(100) UNIQUE NOT NULL,
name varchar(500) UNIQUE NOT NULL
);
INSERT INTO donation_platforms (short, name) VALUES ('patreon', 'Patreon');
INSERT INTO donation_platforms (short, name) VALUES ('bmac', 'Buy Me a Coffee');
INSERT INTO donation_platforms (short, name) VALUES ('paypal', 'PayPal');
INSERT INTO donation_platforms (short, name) VALUES ('github', 'GitHub Sponsors');
INSERT INTO donation_platforms (short, name) VALUES ('ko-fi', 'Ko-fi');
INSERT INTO donation_platforms (short, name) VALUES ('other', 'Other');
CREATE TABLE mods_donations (
joining_mod_id bigint REFERENCES mods ON UPDATE CASCADE NOT NULL,
joining_platform_id int REFERENCES donation_platforms ON UPDATE CASCADE NOT NULL,
url varchar(2048) NOT NULL,
PRIMARY KEY (joining_mod_id, joining_platform_id)
);
CREATE TABLE side_types (
id serial PRIMARY KEY,
name varchar(64) UNIQUE NOT NULL
);
INSERT INTO side_types (name) VALUES ('required');
INSERT INTO side_types (name) VALUES ('no-functionality');
INSERT INTO side_types (name) VALUES ('unsupported');
INSERT INTO side_types (name) VALUES ('unknown');
CREATE TABLE licenses (
id serial PRIMARY KEY,
short varchar(60) UNIQUE NOT NULL,
name varchar(1000) UNIQUE NOT NULL
);
INSERT INTO licenses (short, name) VALUES ('custom', 'Custom License');
ALTER TABLE versions
ADD COLUMN featured BOOLEAN NOT NULL default FALSE;
ALTER TABLE files
ADD COLUMN is_primary BOOLEAN NOT NULL default FALSE;
ALTER TABLE mods
ADD COLUMN license integer REFERENCES licenses NOT NULL default 1;
ALTER TABLE mods
ADD COLUMN license_url varchar(1000) NULL;
ALTER TABLE mods
ADD COLUMN client_side integer REFERENCES side_types NOT NULL default 4;
ALTER TABLE mods
ADD COLUMN server_side integer REFERENCES side_types NOT NULL default 4;
ALTER TABLE mods
ADD COLUMN discord_url varchar(255) NULL;
ALTER TABLE mods
ADD COLUMN slug varchar(255) NULL UNIQUE;
CREATE TABLE downloads (
id serial PRIMARY KEY,
version_id bigint REFERENCES versions ON UPDATE CASCADE NOT NULL,
date timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL,
-- A SHA1 hash of the downloader IP address
identifier varchar(40) NOT NULL
);

View File

@@ -0,0 +1,5 @@
-- Add migration script here
ALTER TABLE team_members
DROP COLUMN member_name;
UPDATE side_types SET name = 'optional' WHERE name = 'no-functionality';

View File

@@ -0,0 +1,15 @@
ALTER TABLE mods
ADD COLUMN body varchar(65536) NOT NULL DEFAULT '';
ALTER TABLE mods
ALTER COLUMN body_url DROP NOT NULL;
ALTER TABLE versions
ADD COLUMN changelog varchar(65536) NOT NULL DEFAULT '';
INSERT INTO users (
id, github_id, username, name, email,
avatar_url, bio, created
)
VALUES (
127155982985829, 10137, 'Ghost', NULL, NULL,
'https://avatars2.githubusercontent.com/u/10137', 'A deleted user', NOW()
);

View File

@@ -0,0 +1,3 @@
-- Add migration script here
ALTER TABLE versions
DROP COLUMN accepted;

View File

@@ -0,0 +1,3 @@
-- Add migration script here
ALTER TABLE dependencies
ADD COLUMN dependency_type varchar(255) NOT NULL DEFAULT 'required';

View File

@@ -0,0 +1,24 @@
CREATE TABLE report_types (
id serial PRIMARY KEY,
name varchar(64) UNIQUE NOT NULL
);
INSERT INTO report_types (name) VALUES ('spam');
INSERT INTO report_types (name) VALUES ('copyright');
INSERT INTO report_types (name) VALUES ('inappropriate');
INSERT INTO report_types (name) VALUES ('malicious');
INSERT INTO report_types (name) VALUES ('name-squatting');
CREATE TABLE reports (
id bigint PRIMARY KEY,
report_type_id int REFERENCES report_types ON UPDATE CASCADE NOT NULL,
mod_id bigint REFERENCES mods ON UPDATE CASCADE,
version_id bigint REFERENCES versions ON UPDATE CASCADE,
user_id bigint REFERENCES users ON UPDATE CASCADE,
body varchar(65536) NOT NULL,
reporter bigint REFERENCES users ON UPDATE CASCADE NOT NULL,
created timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL
);
ALTER TABLE game_versions
ADD COLUMN major boolean NOT NULL DEFAULT FALSE;

View File

@@ -0,0 +1,18 @@
-- Add migration script here
CREATE TABLE notifications (
id bigint PRIMARY KEY,
user_id bigint REFERENCES users NOT NULL,
title varchar(255) NOT NULL,
text varchar(2048) NOT NULL,
link varchar(2048) NOT NULL,
created timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL,
read boolean DEFAULT FALSE NOT NULL
);
CREATE TABLE notifications_actions (
id serial PRIMARY KEY,
notification_id bigint REFERENCES notifications NOT NULL,
title varchar(255) NOT NULL,
action_route varchar(2048) NOT NULL,
action_route_method varchar(32) NOT NULL
);

View File

@@ -0,0 +1,9 @@
CREATE TABLE mod_follows(
follower_id bigint REFERENCES users NOT NULL,
mod_id bigint REFERENCES mods NOT NULL,
created timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (follower_id, mod_id)
);
ALTER TABLE mods
ADD COLUMN follows integer NOT NULL default 0;

View File

@@ -0,0 +1,31 @@
ALTER TABLE users ADD CONSTRAINT username_unique UNIQUE (username);
CREATE TABLE project_types (
id serial PRIMARY KEY,
name varchar(64) UNIQUE NOT NULL
);
INSERT INTO project_types (name) VALUES ('mod');
INSERT INTO project_types (name) VALUES ('modpack');
CREATE TABLE loaders_project_types (
joining_loader_id int REFERENCES loaders ON UPDATE CASCADE NOT NULL,
joining_project_type_id int REFERENCES project_types ON UPDATE CASCADE NOT NULL,
PRIMARY KEY (joining_loader_id, joining_project_type_id)
);
ALTER TABLE mods
ADD COLUMN project_type integer REFERENCES project_types NOT NULL default 1;
ALTER TABLE categories
ADD COLUMN project_type integer REFERENCES project_types NOT NULL default 1,
ADD COLUMN icon varchar(20000) NOT NULL default '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"></path><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>';
ALTER TABLE loaders
ADD COLUMN icon varchar(20000) NOT NULL default '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"></path><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>';
ALTER TABLE mods
ALTER COLUMN project_type DROP DEFAULT;
ALTER TABLE categories
ALTER COLUMN project_type DROP DEFAULT;

View File

@@ -0,0 +1,18 @@
INSERT INTO statuses (status) VALUES ('archived');
ALTER TABLE notifications
ADD COLUMN type varchar(256);
ALTER TABLE mods
ADD COLUMN rejection_reason varchar(2000),
ADD COLUMN rejection_body varchar(65536);
DROP TABLE dependencies;
CREATE TABLE dependencies (
id serial PRIMARY KEY,
dependent_id bigint REFERENCES versions ON UPDATE CASCADE NOT NULL,
dependency_type varchar(255) NOT NULL,
dependency_id bigint REFERENCES versions ON UPDATE CASCADE,
mod_dependency_id bigint REFERENCES mods ON UPDATE CASCADE
);

View File

@@ -0,0 +1,6 @@
-- Add migration script here
CREATE TABLE mods_gallery (
id serial PRIMARY KEY,
mod_id bigint REFERENCES mods ON UPDATE CASCADE NOT NULL,
image_url varchar(2048) NOT NULL
);

View File

@@ -0,0 +1,7 @@
ALTER TABLE mods
RENAME COLUMN rejection_reason TO moderation_message;
ALTER TABLE mods
RENAME COLUMN rejection_body TO moderation_message_body;
ALTER TABLE mods_gallery
ADD COLUMN featured boolean default false;

View File

@@ -0,0 +1,6 @@
ALTER TABLE mods_gallery
ADD COLUMN title varchar(255),
ADD COLUMN description varchar(2048),
ADD COLUMN created timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL;

View File

@@ -0,0 +1,7 @@
ALTER TABLE versions ADD COLUMN version_type varchar(255) default 'release' NOT NULL;
UPDATE versions SET version_type = (SELECT rc.channel FROM release_channels rc WHERE rc.id = release_channel);
ALTER TABLE versions DROP COLUMN release_channel, ALTER COLUMN version_type DROP DEFAULT;
DROP TABLE release_channels;

View File

@@ -0,0 +1 @@
ALTER TABLE categories DROP CONSTRAINT IF EXISTS categories_category_key;

View File

@@ -0,0 +1 @@
DROP TABLE downloads;

View File

@@ -0,0 +1 @@
ALTER TABLE files ADD COLUMN size integer NOT NULL default 0;

View File

@@ -0,0 +1,2 @@
ALTER TABLE dependencies
ADD COLUMN dependency_file_name varchar(1024) NULL;

View File

@@ -0,0 +1,37 @@
-- Add migration script here
ALTER TABLE mods_categories
ADD COLUMN is_additional BOOLEAN NOT NULL DEFAULT FALSE;
ALTER TABLE mods
ADD COLUMN approved timestamptz NULL;
ALTER TABLE categories
ADD COLUMN header varchar(256) NOT NULL DEFAULT 'Categories';
UPDATE mods
SET approved = published
WHERE status = 1 OR status = 4;
CREATE INDEX mods_slug
ON mods (slug);
CREATE INDEX versions_mod_id
ON versions (mod_id);
CREATE INDEX files_version_id
ON files (version_id);
CREATE INDEX dependencies_dependent_id
ON dependencies (dependent_id);
CREATE INDEX mods_gallery_mod_id
ON mods_gallery(mod_id);
CREATE INDEX game_versions_versions_joining_version_id
ON game_versions_versions(joining_version_id);
CREATE INDEX loaders_versions_version_id
ON loaders_versions(version_id);
CREATE INDEX notifications_user_id
ON notifications(user_id);

View File

@@ -0,0 +1,3 @@
CREATE TABLE banned_users (
github_id bigint NOT NULL PRIMARY KEY UNIQUE
)

View File

@@ -0,0 +1,7 @@
ALTER TABLE team_members ADD COLUMN payouts_split REAL NOT NULL DEFAULT 0;
UPDATE team_members
SET permissions = 1023, payouts_split = 100
WHERE role = 'Owner';
ALTER TABLE users ADD COLUMN badges bigint default 0 NOT NULL;

View File

@@ -0,0 +1,29 @@
ALTER TABLE team_members DROP COLUMN payouts_split;
ALTER TABLE team_members ADD COLUMN payouts_split numeric(96, 48) NOT NULL DEFAULT 0;
UPDATE team_members
SET payouts_split = 100
WHERE role = 'Owner';
CREATE TABLE payouts_values (
id bigserial PRIMARY KEY,
user_id bigint REFERENCES users NOT NULL,
mod_id bigint REFERENCES mods NULL,
amount numeric(96, 48) NOT NULL,
created timestamptz NOT NULL,
claimed BOOLEAN NOT NULL DEFAULT FALSE
);
CREATE INDEX payouts_values_user_id
ON payouts_values (user_id);
CREATE INDEX payouts_values_mod_id
ON payouts_values (mod_id);
CREATE INDEX payouts_values_created
ON payouts_values (created);
ALTER TABLE users ADD COLUMN midas_expires timestamptz NULL;
ALTER TABLE users ADD COLUMN is_overdue BOOLEAN NULL;
ALTER TABLE users ADD COLUMN stripe_customer_id varchar(255) NULL;
ALTER TABLE users ADD COLUMN paypal_email varchar(128) NULL;

View File

@@ -0,0 +1,24 @@
ALTER TABLE users DROP COLUMN paypal_email;
ALTER TABLE payouts_values DROP COLUMN claimed;
ALTER TABLE users ADD COLUMN payout_wallet varchar(128) NULL;
ALTER TABLE users ADD COLUMN payout_wallet_type varchar(128) NULL;
ALTER TABLE users ADD COLUMN payout_address varchar(128) NULL;
ALTER TABLE users ADD COLUMN balance numeric(96, 48) NOT NULL DEFAULT 0;
UPDATE users
SET balance = COALESCE((SELECT SUM(T2.amount) FROM payouts_values T2 WHERE T2.user_id = users.id), 0, 0)
WHERE id > 1;
CREATE TABLE historical_payouts (
id bigserial PRIMARY KEY,
user_id bigint REFERENCES users NOT NULL,
amount numeric(96, 48) NOT NULL,
created timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL,
status varchar(128) NOT NULL
);
DELETE FROM payouts_values WHERE amount = 0;
CREATE INDEX historical_payouts_user_id
ON historical_payouts (user_id);

View File

@@ -0,0 +1 @@
ALTER TABLE users ALTER balance TYPE numeric(40, 30);

View File

@@ -0,0 +1,2 @@
-- Add migration script here
ALTER TABLE users ALTER balance TYPE numeric(40, 20);

View File

@@ -0,0 +1,6 @@
-- Add migration script here
ALTER TABLE payouts_values ALTER amount TYPE numeric(40, 20);
ALTER TABLE users ADD COLUMN flame_anvil_key varchar(40) NULL;
ALTER TABLE mods ADD COLUMN flame_anvil_project integer NULL;
ALTER TABLE mods ADD COLUMN flame_anvil_user bigint REFERENCES users NULL;

View File

@@ -0,0 +1,27 @@
ALTER TABLE mods ADD COLUMN license_new varchar(2048) DEFAULT 'LicenseRef-All-Rights-Reserved' NOT NULL;
UPDATE mods SET license_new = licenses.short FROM licenses WHERE mods.license = licenses.id;
UPDATE mods SET license_new = 'LicenseRef-Custom' WHERE license_new = 'custom';
UPDATE mods SET license_new = 'LicenseRef-All-Rights-Reserved' WHERE license_new = 'arr';
UPDATE mods SET license_new = 'Apache-2.0' WHERE license_new = 'apache';
UPDATE mods SET license_new = 'BSD-2-Clause' WHERE license_new = 'bsd-2-clause';
UPDATE mods SET license_new = 'BSD-3-Clause' WHERE license_new = 'bsd-3-clause' OR license_new = 'bsd';
UPDATE mods SET license_new = 'CC0-1.0' WHERE license_new = 'cc0';
UPDATE mods SET license_new = 'Unlicense' WHERE license_new = 'unlicense';
UPDATE mods SET license_new = 'MIT' WHERE license_new = 'mit';
UPDATE mods SET license_new = 'LGPL-3.0-only' WHERE license_new = 'lgpl-3';
UPDATE mods SET license_new = 'LGPL-2.1-only' WHERE license_new = 'lgpl-2.1' OR license_new = 'lgpl';
UPDATE mods SET license_new = 'MPL-2.0' WHERE license_new = 'mpl-2';
UPDATE mods SET license_new = 'ISC' WHERE license_new = 'isc';
UPDATE mods SET license_new = 'Zlib' WHERE license_new = 'zlib';
UPDATE mods SET license_new = 'GPL-2.0-only' WHERE license_new = 'gpl-2';
UPDATE mods SET license_new = 'GPL-3.0-only' WHERE license_new = 'gpl-3';
UPDATE mods SET license_new = 'AGPL-3.0-only' WHERE license_new = 'agpl';
UPDATE mods SET license_url = NULL WHERE license_url LIKE 'https://cdn.modrinth.com/licenses/%';
ALTER TABLE mods DROP COLUMN license;
ALTER TABLE mods RENAME COLUMN license_new TO license;
DROP TABLE licenses;

View File

@@ -0,0 +1,23 @@
-- Add migration script here
ALTER TABLE mods ADD COLUMN updated_status varchar(128) NULL;
ALTER TABLE mods ADD COLUMN requested_status varchar(128) NULL;
UPDATE mods
SET updated_status = (
SELECT s.status
FROM statuses s
WHERE s.id = mods.status
);
ALTER TABLE mods
DROP COLUMN status;
ALTER TABLE mods
RENAME COLUMN updated_status TO status;
DROP TABLE statuses;
ALTER TABLE mods ALTER COLUMN status SET NOT NULL;
ALTER TABlE versions ADD COLUMN status varchar(128) NOT NULL DEFAULT 'listed';
ALTER TABLE versions ADD COLUMN requested_status varchar(128) NULL;

View File

@@ -0,0 +1,9 @@
-- Add migration script here
ALTER TABLE mods ADD COLUMN webhook_sent BOOL NOT NULL DEFAULT FALSE;
UPDATE mods
SET webhook_sent = (status = 'approved');
UPDATE mods
SET status = 'withheld'
WHERE status = 'unlisted';

View File

@@ -0,0 +1,3 @@
ALTER TABLE categories ADD COLUMN ordering BIGINT NOT NULL DEFAULT 0;
ALTER TABLE mods_gallery ADD COLUMN ordering BIGINT NOT NULL DEFAULT 0;
ALTER TABLE team_members ADD COLUMN ordering BIGINT NOT NULL DEFAULT 0;

View File

@@ -0,0 +1,2 @@
ALTER TABLE mods DROP COLUMN body_url;
ALTER TABLE versions DROP COLUMN changelog_url;

View File

@@ -0,0 +1,2 @@
-- Add migration script here
ALTER TABLE files ADD COLUMN file_type varchar(128) NULL;

View File

@@ -0,0 +1,2 @@
-- Add migration script here
ALTER TABLE mods ADD COLUMN color integer NULL;

View File

@@ -0,0 +1,4 @@
-- Add migration script here
DROP EXTENSION IF EXISTS tsm_system_rows;
CREATE EXTENSION tsm_system_rows;

View File

@@ -0,0 +1,21 @@
-- Add migration script here
ALTER TABLE mods ADD COLUMN loaders varchar(255)[] NOT NULL default array[]::varchar[];
ALTER TABLE mods ADD COLUMN game_versions varchar(255)[] NOT NULL default array[]::varchar[];
UPDATE mods
SET loaders = (
SELECT COALESCE(ARRAY_AGG(DISTINCT l.loader) filter (where l.loader is not null), array[]::varchar[])
FROM versions v
INNER JOIN loaders_versions lv ON lv.version_id = v.id
INNER JOIN loaders l on lv.loader_id = l.id
WHERE v.mod_id = mods.id
);
UPDATE mods
SET game_versions = (
SELECT COALESCE(ARRAY_AGG(DISTINCT gv.version) filter (where gv.version is not null), array[]::varchar[])
FROM versions v
INNER JOIN game_versions_versions gvv ON v.id = gvv.joining_version_id
INNER JOIN game_versions gv on gvv.game_version_id = gv.id
WHERE v.mod_id = mods.id
);

View File

@@ -0,0 +1,2 @@
-- Add migration script here
ALTER TABLE mods ADD COLUMN queued timestamptz NULL

View File

@@ -0,0 +1,32 @@
-- Add migration script here
-- Add route for users to see their own reports
CREATE TABLE threads (
id bigint PRIMARY KEY,
-- can be either "report", "project", or "direct_message". direct message is unused for now
thread_type VARCHAR(64) NOT NULL
);
CREATE TABLE threads_messages (
id bigint PRIMARY KEY,
thread_id bigint REFERENCES threads ON UPDATE CASCADE NOT NULL,
-- If this is null, it's a system message
author_id bigint REFERENCES users ON UPDATE CASCADE NULL,
body jsonb NOT NULL,
created timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL,
show_in_mod_inbox BOOLEAN NOT NULL DEFAULT FALSE
);
CREATE TABLE threads_members (
thread_id bigint REFERENCES threads ON UPDATE CASCADE NOT NULL,
user_id bigint REFERENCES users ON UPDATE CASCADE NOT NULL,
PRIMARY KEY (thread_id, user_id)
);
ALTER TABLE reports
ADD COLUMN closed boolean NOT NULL DEFAULT FALSE;
ALTER TABLE reports
ADD COLUMN thread_id bigint references threads ON UPDATE CASCADE;
ALTER TABLE mods
ADD COLUMN thread_id bigint references threads ON UPDATE CASCADE;

View File

@@ -0,0 +1,10 @@
ALTER TABLE threads ADD COLUMN show_in_mod_inbox BOOLEAN NOT NULL DEFAULT FALSE;
ALTER TABLE threads_messages DROP COLUMN show_in_mod_inbox;
ALTER TABLE notifications ADD COLUMN body jsonb NULL;
ALTER TABLE notifications ALTER COLUMN title DROP NOT NULL;
ALTER TABLE notifications ALTER COLUMN text DROP NOT NULL;
ALTER TABLE notifications ALTER COLUMN link DROP NOT NULL;
ALTER TABLE threads ADD COLUMN report_id bigint REFERENCES reports ON UPDATE CASCADE;
ALTER TABLE threads ADD COLUMN project_id bigint REFERENCES mods ON UPDATE CASCADE;

View File

@@ -0,0 +1,10 @@
UPDATE dependencies AS d
SET mod_dependency_id = v.mod_id
FROM versions AS v
WHERE v.id = d.dependency_id;
ALTER TABLE users DROP COLUMN flame_anvil_key;
ALTER TABLE mods DROP COLUMN flame_anvil_project;
ALTER TABLE mods DROP COLUMN flame_anvil_user;
ALTER TABLE mods ADD COLUMN monetization_status varchar(64) NOT NULL default 'monetized';

View File

@@ -0,0 +1,2 @@
ALTER TABLE threads DROP COLUMN project_id;
ALTER TABLE threads DROP COLUMN report_id;

View File

@@ -0,0 +1,16 @@
-- No longer have banned users in Labrinth
DROP TABLE banned_users;
-- Initialize kratos_id
ALTER TABLE users ADD COLUMN kratos_id varchar(40) UNIQUE;
-- Add pats table
CREATE TABLE pats (
id BIGINT PRIMARY KEY,
name VARCHAR(255),
user_id BIGINT NOT NULL REFERENCES users(id),
access_token VARCHAR(64) NOT NULL,
scope BIGINT NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
expires_at TIMESTAMP NOT NULL
);

View File

@@ -0,0 +1,48 @@
ALTER TABLE users DROP COLUMN kratos_id;
ALTER TABLE states ADD COLUMN provider varchar(64) NOT NULL default 'github';
ALTER TABLE users ADD COLUMN discord_id bigint;
ALTER TABLE users ADD COLUMN gitlab_id bigint;
ALTER TABLE users ADD COLUMN google_id varchar(256);
ALTER TABLE users ADD COLUMN steam_id bigint;
ALTER TABLE users ADD COLUMN microsoft_id varchar(256);
CREATE INDEX users_discord_id
ON users (discord_id);
CREATE INDEX users_gitlab_id
ON users (gitlab_id);
CREATE INDEX users_google_id
ON users (google_id);
CREATE INDEX users_steam_id
ON users (steam_id);
CREATE INDEX users_microsoft_id
ON users (microsoft_id);
ALTER TABLE users ALTER COLUMN avatar_url TYPE varchar(1024);
ALTER TABLE users ADD COLUMN password TEXT NULL;
ALTER TABLE users ADD COLUMN email_verified BOOLEAN NOT NULL DEFAULT FALSE;
CREATE TABLE sessions (
id bigint NOT NULL PRIMARY KEY,
session varchar(64) NOT NULL UNIQUE,
user_id BIGINT NOT NULL REFERENCES users(id),
created timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL,
last_login timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL,
expires timestamptz DEFAULT CURRENT_TIMESTAMP + interval '14 days' NOT NULL,
refresh_expires timestamptz DEFAULT CURRENT_TIMESTAMP + interval '60 days' NOT NULL,
city varchar(256) NULL,
country varchar(256) NULL,
ip varchar(512) NOT NULL,
os varchar(256) NULL,
platform varchar(256) NULL,
user_agent varchar(1024) NOT NULL
);
CREATE INDEX sessions_user_id
ON sessions (user_id);
ALTER TABLE mods DROP COLUMN game_versions;
ALTER TABLE mods DROP COLUMN loaders;

View File

@@ -0,0 +1,44 @@
CREATE INDEX sessions_session
ON sessions (session);
CREATE TABLE flows (
id bigint NOT NULL PRIMARY KEY,
flow varchar(64) NOT NULL UNIQUE,
user_id BIGINT NOT NULL REFERENCES users(id),
expires timestamptz NOT NULL,
flow_type varchar(64) NOT NULL
);
CREATE INDEX flows_flow
ON flows (flow);
DROP TABLE pats;
CREATE TABLE pats (
id BIGINT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
user_id BIGINT NOT NULL REFERENCES users(id),
access_token VARCHAR(64) NOT NULL UNIQUE,
scopes BIGINT NOT NULL,
created timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
expires timestamptz NOT NULL,
last_used timestamptz NULL
);
CREATE INDEX pats_user_id
ON pats (user_id);
CREATE INDEX pats_access_token
ON pats (access_token);
ALTER TABLE mods DROP COLUMN thread_id;
ALTER TABLE reports DROP COLUMN thread_id;
DELETE FROM threads_members;
DELETE FROM threads_messages;
DELETE FROM threads;
ALTER TABLE threads
ADD COLUMN report_id bigint references reports ON UPDATE CASCADE NULL;
ALTER TABLE threads
ADD COLUMN mod_id bigint references mods ON UPDATE CASCADE NULL;

View File

@@ -0,0 +1,15 @@
-- Add migration script here
ALTER TABLE states ADD COLUMN user_id bigint references users ON UPDATE CASCADE NULL;
ALTER TABLE users ADD COLUMN totp_secret varchar(24) null;
ALTER TABLE users ADD CONSTRAINT email_unique UNIQUE (email);
DROP TABLE flows;
DROP TABLE states;
CREATE TABLE user_backup_codes (
user_id BIGINT NOT NULL REFERENCES users(id),
code BIGINT NOT NULL,
PRIMARY KEY (user_id, code)
);

View File

@@ -0,0 +1 @@
ALTER TABLE users ALTER COLUMN totp_secret TYPE varchar(32);

View File

@@ -0,0 +1,4 @@
CREATE INDEX threads_report_id
ON threads (report_id);
CREATE INDEX threads_mod_id
ON threads (mod_id);

View File

@@ -0,0 +1,20 @@
ALTER TABLE mods ADD COLUMN loaders varchar(255)[] NOT NULL default array[]::varchar[];
ALTER TABLE mods ADD COLUMN game_versions varchar(255)[] NOT NULL default array[]::varchar[];
UPDATE mods
SET loaders = (
SELECT COALESCE(ARRAY_AGG(DISTINCT l.loader) filter (where l.loader is not null), array[]::varchar[])
FROM versions v
INNER JOIN loaders_versions lv ON lv.version_id = v.id
INNER JOIN loaders l on lv.loader_id = l.id
WHERE v.mod_id = mods.id
);
UPDATE mods
SET game_versions = (
SELECT COALESCE(ARRAY_AGG(DISTINCT gv.version) filter (where gv.version is not null), array[]::varchar[])
FROM versions v
INNER JOIN game_versions_versions gvv ON v.id = gvv.joining_version_id
INNER JOIN game_versions gv on gvv.game_version_id = gv.id
WHERE v.mod_id = mods.id
);

View File

@@ -0,0 +1,37 @@
CREATE TABLE collections (
id bigint PRIMARY KEY,
title varchar(255) NOT NULL,
description varchar(2048) NOT NULL,
user_id bigint REFERENCES users NOT NULL,
created timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
status varchar(64) NOT NULL DEFAULT 'listed',
icon_url varchar(2048) NULL,
color integer NULL
);
CREATE TABLE collections_mods (
collection_id bigint REFERENCES collections NOT NULL,
mod_id bigint REFERENCES mods NOT NULL,
PRIMARY KEY (collection_id, mod_id)
);
CREATE TABLE uploaded_images (
id bigint PRIMARY KEY,
url varchar(2048) NOT NULL,
size integer NOT NULL,
created timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
owner_id bigint REFERENCES users NOT NULL,
-- Type of contextual association
context varchar(64) NOT NULL, -- project, version, thread_message, report, etc.
-- Only one of these should be set (based on 'context')
mod_id bigint NULL REFERENCES mods,
version_id bigint NULL REFERENCES versions,
thread_message_id bigint NULL REFERENCES threads_messages,
report_id bigint NULL REFERENCES reports
);

View File

@@ -0,0 +1,17 @@
CREATE TABLE organizations (
id bigint PRIMARY KEY,
title varchar(255) NOT NULL, -- also slug
description text NOT NULL,
created_at timestamp NOT NULL DEFAULT now(),
updated_at timestamp NOT NULL DEFAULT now(),
team_id bigint NOT NULL REFERENCES teams(id) ON UPDATE CASCADE,
icon_url varchar(255) NULL,
color integer NULL
);
ALTER TABLE mods ADD COLUMN organization_id bigint NULL REFERENCES organizations(id) ON DELETE SET NULL;
-- Organization permissions only apply to teams that are associated to an organization
-- If they do, 'permissions' is considered the fallback permissions for projects in the organization
ALTER TABLE team_members ADD COLUMN organization_permissions bigint NULL;

View File

@@ -0,0 +1,180 @@
CREATE TABLE games (
id int PRIMARY KEY, -- Only used in db
name varchar(64),
CONSTRAINT unique_game_name UNIQUE (name)
);
INSERT INTO games(id, name) VALUES (1, 'minecraft-java');
INSERT INTO games(id, name) VALUES (2, 'minecraft-bedrock');
ALTER TABLE loaders ADD CONSTRAINT unique_loader_name UNIQUE (loader);
CREATE TABLE loader_field_enums (
id serial PRIMARY KEY,
enum_name varchar(64) NOT NULL,
ordering int NULL,
hidable BOOLEAN NOT NULL DEFAULT FALSE
);
CREATE TABLE loader_field_enum_values (
id serial PRIMARY KEY,
enum_id integer REFERENCES loader_field_enums NOT NULL,
value varchar(64) NOT NULL,
ordering int NULL,
created timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
-- metadata is json of all the extra data for this enum value
metadata jsonb NULL,
original_id integer, -- This is for mapping only- it is dropped before the end of the migration
CONSTRAINT unique_variant_per_enum UNIQUE (enum_id, value)
);
CREATE TABLE loader_fields (
id serial PRIMARY KEY,
field varchar(64) UNIQUE NOT NULL,
-- "integer", "text", "enum", "bool",
-- "array_integer", "array_text", "array_enum", "array_bool"
field_type varchar(64) NOT NULL,
-- only for enum
enum_type integer REFERENCES loader_field_enums NULL,
optional BOOLEAN NOT NULL DEFAULT true,
-- for int- min/max val, for text- min len, for enum- min items, for bool- nothing
min_val integer NULL,
max_val integer NULL
);
CREATE TABLE loader_fields_loaders (
loader_id integer REFERENCES loaders NOT NULL,
loader_field_id integer REFERENCES loader_fields NOT NULL,
CONSTRAINT unique_loader_field UNIQUE (loader_id, loader_field_id)
);
ALTER TABLE loaders ADD COLUMN hidable boolean NOT NULL default false;
CREATE TABLE version_fields (
version_id bigint REFERENCES versions NOT NULL,
field_id integer REFERENCES loader_fields NOT NULL,
-- for int/bool values
int_value integer NULL,
enum_value integer REFERENCES loader_field_enum_values NULL,
string_value text NULL
);
-- Convert side_types
INSERT INTO loader_field_enums (id, enum_name, hidable) VALUES (1, 'side_types', true);
INSERT INTO loader_field_enum_values (original_id, enum_id, value) SELECT id, 1, name FROM side_types st;
INSERT INTO loader_fields (field, field_type, enum_type, optional, min_val, max_val) SELECT 'client_side', 'enum', 1, false, 1, 1;
INSERT INTO loader_fields ( field, field_type, enum_type, optional, min_val, max_val) SELECT 'server_side', 'enum', 1, false, 1, 1;
INSERT INTO loader_fields_loaders (loader_id, loader_field_id) SELECT l.id, lf.id FROM loaders l CROSS JOIN loader_fields lf WHERE lf.field = 'client_side' AND l.loader = ANY( ARRAY['forge', 'fabric', 'quilt', 'modloader','rift','liteloader', 'neoforge']);
INSERT INTO loader_fields_loaders (loader_id, loader_field_id) SELECT l.id, lf.id FROM loaders l CROSS JOIN loader_fields lf WHERE lf.field = 'server_side' AND l.loader = ANY( ARRAY['forge', 'fabric', 'quilt', 'modloader','rift','liteloader', 'neoforge']);
INSERT INTO version_fields (version_id, field_id, enum_value)
SELECT v.id, lf.id, lfev.id -- Note: bug fix/edited 2023-11-27
FROM versions v
INNER JOIN mods m ON v.mod_id = m.id
INNER JOIN loader_field_enum_values lfev ON m.client_side = lfev.original_id
CROSS JOIN loader_fields lf
WHERE client_side IS NOT NULL AND lfev.enum_id = 1 AND lf.field = 'client_side' AND NOT (ARRAY['vanilla', 'minecraft', 'optifine', 'iris', 'canvas', 'bukkit', 'folia', 'paper', 'purpur', 'spigot', 'sponge', 'datapack', 'bungeecord', 'velocity', 'waterfall'] @> m.loaders::text[]);;
INSERT INTO version_fields (version_id, field_id, enum_value)
SELECT v.id, lf.id, lfev.id -- Note: bug fix/edited 2023-11-27
FROM versions v
INNER JOIN mods m ON v.mod_id = m.id
INNER JOIN loader_field_enum_values lfev ON m.server_side = lfev.original_id
CROSS JOIN loader_fields lf
WHERE server_side IS NOT NULL AND lfev.enum_id = 1 AND lf.field = 'server_side' AND NOT (ARRAY['vanilla', 'minecraft', 'optifine', 'iris', 'canvas', 'bukkit', 'folia', 'paper', 'purpur', 'spigot', 'sponge', 'datapack', 'bungeecord', 'velocity', 'waterfall'] @> m.loaders::text[]);
ALTER TABLE mods DROP COLUMN client_side;
ALTER TABLE mods DROP COLUMN server_side;
DROP TABLE side_types;
-- Convert game_versions
INSERT INTO loader_field_enums (id, enum_name, hidable) VALUES (2, 'game_versions', true);
INSERT INTO loader_field_enum_values (original_id, enum_id, value, created, metadata)
SELECT id, 2, version, created, json_build_object('type', type, 'major', major) FROM game_versions;
INSERT INTO loader_fields (field, field_type, enum_type, optional, min_val) VALUES('game_versions', 'array_enum', 2, false, 0);
INSERT INTO loader_fields_loaders (loader_id, loader_field_id) SELECT l.id, lf.id FROM loaders l CROSS JOIN loader_fields lf WHERE lf.field = 'game_versions' AND l.loader = ANY( ARRAY['forge', 'fabric', 'quilt', 'modloader','rift','liteloader', 'neoforge']);
-- remove dangling game versions
DELETE FROM game_versions_versions
WHERE joining_version_id NOT IN (SELECT id FROM versions);
INSERT INTO version_fields(version_id, field_id, enum_value)
SELECT gvv.joining_version_id, lf.id, lfev.id
FROM game_versions_versions gvv INNER JOIN loader_field_enum_values lfev ON gvv.game_version_id = lfev.original_id
CROSS JOIN loader_fields lf
WHERE lf.field = 'game_versions' AND lfev.enum_id = 2;
ALTER TABLE mods DROP COLUMN loaders;
ALTER TABLE mods DROP COLUMN game_versions;
DROP TABLE game_versions_versions;
DROP TABLE game_versions;
-- Convert project types
-- we are creating a new loader type- 'mrpack'- for minecraft modpacks
SELECT setval('loaders_id_seq', (SELECT MAX(id) FROM loaders) + 1, false);
INSERT INTO loaders (loader) VALUES ('mrpack');
-- For the loader 'mrpack', we create loader fields for every loader
-- That way we keep information like "this modpack is a fabric modpack"
INSERT INTO loader_field_enums (id, enum_name, hidable) VALUES (3, 'mrpack_loaders', true);
INSERT INTO loader_field_enum_values (original_id, enum_id, value) SELECT id, 3, loader FROM loaders WHERE loader != 'mrpack';
INSERT INTO loader_fields (field, field_type, enum_type, optional, min_val) VALUES('mrpack_loaders', 'array_enum', 3, false, 0);
INSERT INTO loader_fields_loaders (loader_id, loader_field_id)
SELECT l.id, lf.id FROM loaders l CROSS JOIN loader_fields lf WHERE lf.field = 'mrpack_loaders' AND l.loader = 'mrpack';
INSERT INTO version_fields(version_id, field_id, enum_value)
SELECT v.id, lf.id, lfev.id
FROM versions v
INNER JOIN mods m ON v.mod_id = m.id
INNER JOIN loaders_versions lv ON v.id = lv.version_id
INNER JOIN loaders l ON lv.loader_id = l.id
CROSS JOIN loader_fields lf
LEFT JOIN loader_field_enum_values lfev ON lf.enum_type = lfev.enum_id AND lfev.original_id = l.id
WHERE m.project_type = (SELECT id FROM project_types WHERE name = 'modpack') AND lf.field = 'mrpack_loaders';
INSERT INTO loaders_project_types (joining_loader_id, joining_project_type_id) SELECT DISTINCT l.id, pt.id FROM loaders l CROSS JOIN project_types pt WHERE pt.name = 'modpack' AND l.loader = 'mrpack';
-- Set those versions to mrpack as their version
INSERT INTO loaders_versions (version_id, loader_id)
SELECT DISTINCT vf.version_id, l.id
FROM version_fields vf
LEFT JOIN loader_fields lf ON lf.id = vf.field_id
CROSS JOIN loaders l
WHERE lf.field = 'mrpack_loaders'
AND l.loader = 'mrpack'
ON CONFLICT DO NOTHING;
-- Delete the old versions that had mrpack added to them
DELETE FROM loaders_versions lv
WHERE lv.loader_id != (SELECT id FROM loaders WHERE loader = 'mrpack')
AND lv.version_id IN (
SELECT version_id
FROM loaders_versions
WHERE loader_id = (SELECT id FROM loaders WHERE loader = 'mrpack')
);
--- Non-mrpack loaders no longer support modpacks
DELETE FROM loaders_project_types WHERE joining_loader_id != (SELECT id FROM loaders WHERE loader = 'mrpack') AND joining_project_type_id = (SELECT id FROM project_types WHERE name = 'modpack');
CREATE TABLE loaders_project_types_games (
loader_id integer REFERENCES loaders NOT NULL,
project_type_id integer REFERENCES project_types NOT NULL,
game_id integer REFERENCES games NOT NULL,
PRIMARY KEY (loader_id, project_type_id, game_id)
);
-- all past loader_project_types are minecraft-java as the only game before this migration is minecraft-java
INSERT INTO loaders_project_types_games (loader_id, project_type_id, game_id) SELECT joining_loader_id, joining_project_type_id, 1 FROM loaders_project_types;
-- Now that loaders are inferred, we can drop the project_type column from mods
ALTER TABLE mods DROP COLUMN project_type;
-- Drop original_id columns
ALTER TABLE loader_field_enum_values DROP COLUMN original_id;

View File

@@ -0,0 +1,34 @@
CREATE TABLE oauth_clients (
id bigint PRIMARY KEY,
name text NOT NULL,
icon_url text NULL,
max_scopes bigint NOT NULL,
secret_hash text NOT NULL,
created timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
created_by bigint NOT NULL REFERENCES users(id)
);
CREATE TABLE oauth_client_redirect_uris (
id bigint PRIMARY KEY,
client_id bigint NOT NULL REFERENCES oauth_clients (id) ON DELETE CASCADE,
uri text
);
CREATE TABLE oauth_client_authorizations (
id bigint PRIMARY KEY,
client_id bigint NOT NULL REFERENCES oauth_clients (id) ON DELETE CASCADE,
user_id bigint NOT NULL REFERENCES users (id) ON DELETE CASCADE,
scopes bigint NOT NULL,
created timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
UNIQUE (client_id, user_id)
);
CREATE TABLE oauth_access_tokens (
id bigint PRIMARY KEY,
authorization_id bigint NOT NULL REFERENCES oauth_client_authorizations(id) ON DELETE CASCADE,
token_hash text NOT NULL UNIQUE,
scopes bigint NOT NULL,
created timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
expires timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP + interval '14 days',
last_used timestamptz NULL
);
CREATE INDEX oauth_client_creator ON oauth_clients(created_by);
CREATE INDEX oauth_redirect_client ON oauth_client_redirect_uris(client_id);
CREATE INDEX oauth_access_token_hash ON oauth_access_tokens(token_hash);

View File

@@ -0,0 +1 @@
ALTER TABLE versions ADD COLUMN ordering int NULL;

View File

@@ -0,0 +1 @@
UPDATE loader_fields SET min_val = 1 WHERE field = 'game_versions';

View File

@@ -0,0 +1,9 @@
ALTER TABLE games ADD COLUMN slug varchar(64);
ALTER TABLE games ADD COLUMN icon_url varchar(2048) NULL;
ALTER TABLE games ADD COLUMN banner_url varchar(2048) NULL;
-- 'minecraft-java' and 'minecraft-bedrock' are the only games- both slug and names (names are for translations)
UPDATE games SET slug = name;
ALTER TABLE games ALTER COLUMN slug SET NOT NULL;
ALTER TABLE games ALTER COLUMN name SET NOT NULL;
ALTER TABLE games ADD CONSTRAINT unique_game_slug UNIQUE (slug);

View File

@@ -0,0 +1,30 @@
ALTER TABLE users DROP COLUMN IF EXISTS paypal_email;
ALTER TABLE users
ADD COLUMN paypal_country text NULL,
ADD COLUMN paypal_email text NULL,
ADD COLUMN paypal_id text NULL,
ADD COLUMN venmo_handle text NULL,
DROP COLUMN midas_expires,
DROP COLUMN is_overdue,
DROP COLUMN stripe_customer_id,
DROP COLUMN payout_wallet,
DROP COLUMN payout_wallet_type,
DROP COLUMN payout_address;
ALTER TABLE historical_payouts
RENAME TO payouts;
ALTER TABLE payouts
ADD COLUMN method text NULL,
ADD COLUMN method_address text NULL,
ADD COLUMN platform_id text NULL,
ADD COLUMN fee numeric(40, 20) NULL,
ALTER COLUMN id TYPE bigint,
ALTER COLUMN id DROP DEFAULT;
UPDATE payouts
SET status = 'success';
DROP SEQUENCE IF EXISTS historical_payouts_id_seq;

View File

@@ -0,0 +1,46 @@
ALTER TABLE loaders ADD COLUMN metadata jsonb NOT NULL DEFAULT '{}'::jsonb;
-- Set 'platform' to 'true' for all plugin loaders
-- From knossos v2
-- pluginLoaders: ['bukkit', 'spigot', 'paper', 'purpur', 'sponge', 'folia'],
-- pluginPlatformLoaders: ['bungeecord', 'waterfall', 'velocity'],
-- allPluginLoaders: [
-- 'bukkit',
-- 'spigot',
-- 'paper',
-- 'purpur',
-- 'sponge',
-- 'bungeecord',
-- 'waterfall',
-- 'velocity',
-- 'folia',
-- ],
-- dataPackLoaders: ['datapack'],
-- modLoaders: ['forge', 'fabric', 'quilt', 'liteloader', 'modloader', 'rift', 'neoforge'],
UPDATE loaders SET metadata = jsonb_set(metadata, '{platform}', 'false'::jsonb) WHERE loader in ('bukkit', 'spigot', 'paper', 'purpur', 'sponge', 'folia');
UPDATE loaders SET metadata = jsonb_set(metadata, '{platform}', 'true'::jsonb) WHERE loader in ('bungeecord', 'waterfall', 'velocity');
INSERT INTO project_types (name) VALUES ('plugin');
INSERT INTO project_types (name) VALUES ('datapack');
INSERT INTO loaders_project_types (joining_loader_id, joining_project_type_id)
SELECT l.id, pt.id
FROM loaders l
CROSS JOIN project_types pt
WHERE l.loader in ('datapack')
AND pt.name = 'datapack';
INSERT INTO loaders_project_types (joining_loader_id, joining_project_type_id)
SELECT l.id, pt.id
FROM loaders l
CROSS JOIN project_types pt
WHERE l.loader in ('bukkit', 'spigot', 'paper', 'purpur', 'sponge', 'bungeecord', 'waterfall', 'velocity', 'folia')
AND pt.name = 'plugin';
INSERT INTO loaders_project_types_games (loader_id, project_type_id, game_id)
SELECT joining_loader_id, joining_project_type_id, g.id
FROM loaders_project_types lpt
INNER JOIN project_types pt ON pt.id = lpt.joining_project_type_id
CROSS JOIN games g
WHERE g.name = 'minecraft'
AND pt.name in ('plugin', 'datapack');

View File

@@ -0,0 +1,114 @@
CREATE INDEX version_fields_version_id ON version_fields (version_id);
CREATE INDEX hashes_file_id ON hashes (file_id);
INSERT INTO loader_fields (field, field_type, optional) SELECT 'singleplayer', 'boolean', false;
INSERT INTO loader_fields (field, field_type, optional) SELECT 'client_and_server', 'boolean', false;
INSERT INTO loader_fields (field, field_type, optional) SELECT 'client_only', 'boolean', false;
INSERT INTO loader_fields (field, field_type, optional) SELECT 'server_only', 'boolean', false;
-- Create 4 temporary columns for the four booleans (makes queries easier)
ALTER TABLE versions ADD COLUMN singleplayer boolean;
ALTER TABLE versions ADD COLUMN client_and_server boolean;
ALTER TABLE versions ADD COLUMN client_only boolean;
ALTER TABLE versions ADD COLUMN server_only boolean;
-- Set singleplayer to be true if either client_side or server_side is 'required' OR 'optional'
UPDATE versions v SET singleplayer = true
FROM version_fields vf
INNER JOIN loader_fields lf ON vf.field_id = lf.id
INNER JOIN loader_field_enum_values lfev ON lf.enum_type = lfev.enum_id AND vf.enum_value = lfev.id
WHERE v.id = vf.version_id
AND (lf.field = 'client_side' OR lf.field = 'server_side') AND (lfev.value = 'required' OR lfev.value = 'optional');
-- Set client and server to be true if either client_side or server_side is 'required' OR 'optional'
UPDATE versions v SET client_and_server = true
FROM version_fields vf
INNER JOIN loader_fields lf ON vf.field_id = lf.id
INNER JOIN loader_field_enum_values lfev ON lf.enum_type = lfev.enum_id AND vf.enum_value = lfev.id
WHERE v.id = vf.version_id
AND (lf.field = 'client_side' OR lf.field = 'server_side') AND (lfev.value = 'required' OR lfev.value = 'optional');
-- -- Set client_only to be true if client_side is 'required' or 'optional', and server_side is 'optional', 'unsupported', or 'unknown'
UPDATE versions v
SET client_only = true
WHERE EXISTS (
SELECT 1
FROM version_fields vf
INNER JOIN loader_fields lf ON vf.field_id = lf.id
INNER JOIN loader_field_enum_values lfev ON lf.enum_type = lfev.enum_id AND vf.enum_value = lfev.id
WHERE v.id = vf.version_id
AND lf.field = 'client_side' AND (lfev.value = 'required' OR lfev.value = 'optional')
)
AND EXISTS (
SELECT 1
FROM version_fields vf2
INNER JOIN loader_fields lf2 ON vf2.field_id = lf2.id
INNER JOIN loader_field_enum_values lfev2 ON lf2.enum_type = lfev2.enum_id AND vf2.enum_value = lfev2.id
WHERE v.id = vf2.version_id
AND lf2.field = 'server_side' AND (lfev2.value = 'optional' OR lfev2.value = 'unsupported' OR lfev2.value = 'unknown')
);
-- -- Set server_only to be true if server_side is 'required' or 'optional', and client_side is 'optional', 'unsupported', or 'unknown'
UPDATE versions v
SET server_only = true
WHERE EXISTS (
SELECT 1
FROM version_fields vf
INNER JOIN loader_fields lf ON vf.field_id = lf.id
INNER JOIN loader_field_enum_values lfev ON lf.enum_type = lfev.enum_id AND vf.enum_value = lfev.id
WHERE v.id = vf.version_id
AND lf.field = 'server_side' AND (lfev.value = 'required' OR lfev.value = 'optional')
)
AND EXISTS (
SELECT 1
FROM version_fields vf2
INNER JOIN loader_fields lf2 ON vf2.field_id = lf2.id
INNER JOIN loader_field_enum_values lfev2 ON lf2.enum_type = lfev2.enum_id AND vf2.enum_value = lfev2.id
WHERE v.id = vf2.version_id
AND lf2.field = 'client_side' AND (lfev2.value = 'optional' OR lfev2.value = 'unsupported' OR lfev2.value = 'unknown')
);
-- Insert the values into the version_fields table
INSERT INTO version_fields (version_id, field_id, int_value)
SELECT v.id, lf.id, CASE WHEN v.singleplayer THEN 1 ELSE 0 END
FROM versions v
INNER JOIN loader_fields lf ON lf.field = 'singleplayer';
INSERT INTO version_fields (version_id, field_id, int_value)
SELECT v.id, lf.id, CASE WHEN v.client_and_server THEN 1 ELSE 0 END
FROM versions v
INNER JOIN loader_fields lf ON lf.field = 'client_and_server';
INSERT INTO version_fields (version_id, field_id, int_value)
SELECT v.id, lf.id, CASE WHEN v.client_only THEN 1 ELSE 0 END
FROM versions v
INNER JOIN loader_fields lf ON lf.field = 'client_only';
INSERT INTO version_fields (version_id, field_id, int_value)
SELECT v.id, lf.id, CASE WHEN v.server_only THEN 1 ELSE 0 END
FROM versions v
INNER JOIN loader_fields lf ON lf.field = 'server_only';
-- Drop the temporary columns
ALTER TABLE versions DROP COLUMN singleplayer;
ALTER TABLE versions DROP COLUMN client_and_server;
ALTER TABLE versions DROP COLUMN client_only;
ALTER TABLE versions DROP COLUMN server_only;
-- For each loader where loader_fields_loaders is 'client_side' or 'server_side', add the new fields
INSERT INTO loader_fields_loaders (loader_id, loader_field_id)
SELECT lfl.loader_id, lf.id
FROM loader_fields_loaders lfl
CROSS JOIN loader_fields lf
WHERE lfl.loader_field_id IN (SELECT id FROM loader_fields WHERE field = 'client_side' OR field = 'server_side')
AND lf.field IN ('singleplayer', 'client_and_server', 'client_only', 'server_only')
ON CONFLICT DO NOTHING;
-- Drop the old loader_fields_loaders entries
DELETE FROM loader_fields_loaders WHERE loader_field_id IN (SELECT id FROM loader_fields WHERE field = 'client_side' OR field = 'server_side');
-- Drop client_side and server_side loader fields
DELETE FROM version_fields WHERE field_id IN (SELECT id FROM loader_fields WHERE field = 'client_side' OR field = 'server_side');
DELETE FROM loader_field_enum_values WHERE id IN (SELECT enum_type FROM loader_fields WHERE field = 'client_side' OR field = 'server_side');
DELETE FROM loader_fields WHERE field = 'client_side' OR field = 'server_side';
DELETE FROM loader_field_enums WHERE id IN (SELECT enum_type FROM loader_fields WHERE field = 'side_types');

View File

@@ -0,0 +1,69 @@
CREATE TABLE link_platforms (
id SERIAL PRIMARY KEY,
name VARCHAR(16) UNIQUE NOT NULL,
-- Used for v2 conversion
donation BOOLEAN NOT NULL DEFAULT false,
-- Will be removed at the end of the migration
donation_platform_id INTEGER REFERENCES donation_platforms (id)
);
INSERT INTO link_platforms (donation_platform_id, name, donation)
SELECT id, short, true FROM donation_platforms;
INSERT INTO link_platforms (name, donation) VALUES ('issues', false);
INSERT INTO link_platforms (name, donation) VALUES ('wiki', false);
INSERT INTO link_platforms (name, donation) VALUES ('discord', false);
INSERT INTO link_platforms (name, donation) VALUES ('source', false);
INSERT INTO link_platforms (name, donation) VALUES ('site', false);
CREATE TABLE mods_links (
id SERIAL PRIMARY KEY,
joining_mod_id BIGINT NOT NULL REFERENCES mods (id),
joining_platform_id INTEGER NOT NULL REFERENCES link_platforms (id),
url VARCHAR(2048) NOT NULL
);
INSERT INTO mods_links (joining_mod_id, joining_platform_id, url)
SELECT DISTINCT m.id, lp.id, md.url
FROM mods m
INNER JOIN mods_donations md ON m.id = md.joining_mod_id
INNER JOIN donation_platforms dp ON dp.id = md.joining_platform_id
INNER JOIN link_platforms lp ON lp.donation_platform_id = dp.id;
INSERT INTO mods_links (joining_mod_id, joining_platform_id, url)
SELECT DISTINCT m.id, lp.id, issues_url
FROM mods m
CROSS JOIN link_platforms lp
WHERE issues_url IS NOT NULL
AND lp.name = 'issues';
INSERT INTO mods_links (joining_mod_id, joining_platform_id, url)
SELECT DISTINCT m.id, lp.id, wiki_url
FROM mods m
CROSS JOIN link_platforms lp
WHERE wiki_url IS NOT NULL
AND lp.name = 'wiki';
INSERT INTO mods_links (joining_mod_id, joining_platform_id, url)
SELECT DISTINCT m.id, lp.id, discord_url
FROM mods m
CROSS JOIN link_platforms lp
WHERE discord_url IS NOT NULL
AND lp.name = 'discord';
INSERT INTO mods_links (joining_mod_id, joining_platform_id, url)
SELECT DISTINCT m.id, lp.id, source_url
FROM mods m
CROSS JOIN link_platforms lp
WHERE source_url IS NOT NULL
AND lp.name = 'source';
ALTER TABLE mods DROP COLUMN issues_url;
ALTER TABLE mods DROP COLUMN wiki_url;
ALTER TABLE mods DROP COLUMN discord_url;
ALTER TABLE mods DROP COLUMN source_url;
ALTER TABLE link_platforms DROP COLUMN donation_platform_id;
DROP TABLE mods_donations;
DROP TABLE donation_platforms;

View File

@@ -0,0 +1,7 @@
-- Add migration script here
ALTER TABLE
oauth_clients
ADD
COLUMN url text NULL,
ADD
COLUMN description text NULL;

View File

@@ -0,0 +1,16 @@
-- rename 'title' to 'name' in all tables (collections, organizations, mods, mods_gallery, notifications, notifications_actions)
ALTER TABLE collections RENAME COLUMN title TO name;
ALTER TABLE organizations RENAME COLUMN title TO name;
ALTER TABLE mods RENAME COLUMN title TO name;
ALTER TABLE mods_gallery RENAME COLUMN title TO name;
ALTER TABLE notifications RENAME COLUMN title TO name;
ALTER TABLE notifications_actions RENAME COLUMN title TO name;
-- rename project 'description' to 'summary'
-- rename project 'body' to 'description'
ALTER TABLE mods RENAME COLUMN description TO summary;
ALTER TABLE mods RENAME COLUMN body TO description;
-- Adds 'is_owner' boolean to team members table- only one can be true.
ALTER TABLE team_members ADD COLUMN is_owner boolean NOT NULL DEFAULT false;
UPDATE team_members SET is_owner = true WHERE role = 'Owner';

View File

@@ -0,0 +1,31 @@
-- For every loader that has a loaders_project_types entry that connects it to the project_types 'plugin',
-- remove all non plugin project_types entries for that loader.
-- This is to ensure that the plugin project_types is the only one that is used for the plugin loaders
--plugin
DELETE FROM loaders_project_types
WHERE joining_loader_id IN (
SELECT DISTINCT l.id
FROM loaders l
LEFT JOIN loaders_project_types lpt ON lpt.joining_loader_id = l.id
LEFT JOIN project_types pt ON pt.id = lpt.joining_project_type_id
WHERE pt.name = 'plugin'
)
AND joining_project_type_id NOT IN (
SELECT id FROM project_types
WHERE name = 'plugin'
);
--datapack
DELETE FROM loaders_project_types
WHERE joining_loader_id IN (
SELECT DISTINCT l.id
FROM loaders l
LEFT JOIN loaders_project_types lpt ON lpt.joining_loader_id = l.id
LEFT JOIN project_types pt ON pt.id = lpt.joining_project_type_id
WHERE pt.name = 'datapack'
)
AND joining_project_type_id NOT IN (
SELECT id FROM project_types
WHERE name = 'datapack'
);

View File

@@ -0,0 +1,5 @@
-- Adds missing loader_fields_loaders entries for mrpack loader
INSERT INTO loader_fields_loaders
SELECT l.id, lf.id FROM loaders l CROSS JOIN loader_fields lf
WHERE l.loader='mrpack' AND lf.field=ANY(ARRAY['game_versions','client_and_server','server_only','client_only','singleplayer'])
ON CONFLICT DO NOTHING;

View File

@@ -0,0 +1,21 @@
-- Adds loader_fields_loaders entries for all loaders
-- (at this point, they are all Minecraft loaders, and thus have the same fields)
-- These are loaders such as bukkit, minecraft, vanilla, waterfall, velocity... etc
-- This also allows v2 routes (which have things such as client_side to remain to work with these loaders)
INSERT INTO loader_fields_loaders
SELECT l.id, lf.id FROM loaders l CROSS JOIN loader_fields lf
WHERE lf.field=ANY(ARRAY['client_and_server','server_only','client_only','singleplayer'])
AND
l.loader NOT IN ('vanilla', 'minecraft', 'optifine', 'iris', 'canvas', 'bukkit', 'folia', 'paper', 'purpur', 'spigot', 'sponge', 'datapack', 'bungeecord', 'velocity', 'waterfall')
ON CONFLICT DO NOTHING;
INSERT INTO loader_fields_loaders
SELECT l.id, lf.id FROM loaders l CROSS JOIN loader_fields lf
WHERE lf.field=ANY(ARRAY['game_versions'])
ON CONFLICT DO NOTHING;
-- All existing loader_project_types so far should have a games entry as minecraft
INSERT INTO loaders_project_types_games
SELECT lpt.joining_loader_id, lpt.joining_project_type_id, g.id FROM loaders_project_types lpt CROSS JOIN games g
WHERE g.name='minecraft-java'
ON CONFLICT DO NOTHING;

View File

@@ -0,0 +1 @@
ALTER TABLE collections ALTER COLUMN description DROP NOT NULL;

View File

@@ -0,0 +1,10 @@
-- Enforces that there can only be one owner per team
CREATE UNIQUE INDEX idx_one_owner_per_team
ON team_members (team_id)
WHERE is_owner = TRUE;
-- Enforces one team_member per user/team
CREATE UNIQUE INDEX idx_unique_user_team
ON team_members (user_id, team_id);

View File

@@ -0,0 +1,7 @@
-- Add migration script here
ALTER TABLE organizations RENAME COLUMN name TO slug;
ALTER TABLE organizations ADD COLUMN name text NULL;
UPDATE organizations SET name = slug;
ALTER TABLE organizations ALTER COLUMN name SET NOT NULL;

View File

@@ -0,0 +1,19 @@
CREATE TABLE moderation_external_licenses (
id bigint PRIMARY KEY,
title text not null,
status text not null,
link text null,
exceptions text null,
proof text null,
flame_project_id integer null
);
CREATE TABLE moderation_external_files (
sha1 bytea PRIMARY KEY,
external_license_id bigint references moderation_external_licenses not null
);
ALTER TABLE files ADD COLUMN metadata jsonb NULL;
INSERT INTO users (id, username, name, email, avatar_url, bio, role, badges, balance)
VALUES (0, 'AutoMod', 'AutoMod', 'support@modrinth.com', 'https://cdn.modrinth.com/user/2REoufqX/6aabaf2d1fca2935662eca4ce451cd9775054c22.png', 'An automated account performing moderation utilities for Modrinth.', 'moderator', 0, 0)

View File

@@ -0,0 +1,2 @@
ALTER TABLE moderation_external_files ALTER COLUMN sha1 SET NOT NULL;
ALTER TABLE moderation_external_licenses ALTER COLUMN title DROP NOT NULL;

View File

@@ -0,0 +1,9 @@
ALTER TABLE threads DROP COLUMN show_in_mod_inbox;
ALTER TABLE threads_messages ADD COLUMN hide_identity BOOLEAN default false NOT NULL;
UPDATE threads_messages
SET hide_identity = TRUE
FROM users
WHERE threads_messages.author_id = users.id
AND users.role IN ('moderator', 'admin');

View File

@@ -0,0 +1 @@
ALTER TABLE users DROP COLUMN name;

View File

@@ -0,0 +1,34 @@
ALTER TABLE users ADD COLUMN stripe_customer_id TEXT NULL;
CREATE TABLE products (
id bigint PRIMARY KEY,
metadata jsonb NOT NULL,
unitary BOOLEAN NOT NULL DEFAULT FALSE
);
CREATE TABLE products_prices (
id bigint PRIMARY KEY,
product_id bigint REFERENCES products NOT NULL,
currency_code text not null,
prices jsonb NOT NULL
);
CREATE TABLE users_subscriptions (
id bigint PRIMARY KEY,
user_id bigint REFERENCES users NOT NULL,
price_id bigint REFERENCES products_prices NOT NULL,
interval text NOT NULL,
created timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL,
expires timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL,
last_charge timestamptz NULL,
status varchar(255) NOT NULL
);
CREATE UNIQUE INDEX users_stripe_customer_id
ON users (stripe_customer_id);
CREATE INDEX products_prices_product
ON products_prices (product_id);
CREATE INDEX users_subscriptions_users
ON users_subscriptions (user_id);

View File

@@ -0,0 +1,22 @@
ALTER TABLE mods ADD COLUMN raw_icon_url TEXT NULL;
UPDATE mods SET raw_icon_url = icon_url;
ALTER TABLE users ADD COLUMN raw_avatar_url TEXT NULL;
UPDATE users SET raw_avatar_url = avatar_url;
ALTER TABLE oauth_clients ADD COLUMN raw_icon_url TEXT NULL;
UPDATE oauth_clients SET raw_icon_url = icon_url;
ALTER TABLE organizations ADD COLUMN raw_icon_url TEXT NULL;
UPDATE organizations SET raw_icon_url = icon_url;
ALTER TABLE collections ADD COLUMN raw_icon_url TEXT NULL;
UPDATE collections SET raw_icon_url = icon_url;
ALTER TABLE mods_gallery ADD COLUMN raw_image_url TEXT NULL;
UPDATE mods_gallery SET raw_image_url = image_url;
ALTER TABLE mods_gallery ALTER COLUMN raw_image_url SET NOT NULL;
ALTER TABLE uploaded_images ADD COLUMN raw_url TEXT NULL;
UPDATE uploaded_images SET raw_url = url;
ALTER TABLE uploaded_images ALTER COLUMN raw_url SET NOT NULL;

View File

@@ -0,0 +1,2 @@
ALTER TABLE payouts_values ADD COLUMN date_available timestamptz NOT NULL DEFAULT now();
ALTER TABLE payouts_values ALTER COLUMN date_available DROP DEFAULT;

View File

@@ -0,0 +1,17 @@
CREATE TABLE charges (
id bigint PRIMARY KEY,
user_id bigint REFERENCES users NOT NULL,
price_id bigint REFERENCES products_prices NOT NULL,
amount bigint NOT NULL,
currency_code text NOT NULL,
status varchar(255) NOT NULL,
due timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL,
last_attempt timestamptz NULL,
charge_type text NOT NULL,
subscription_id bigint NULL,
subscription_interval text NULL
);
ALTER TABLE users_subscriptions DROP COLUMN last_charge;
ALTER TABLE users_subscriptions ADD COLUMN metadata jsonb NULL;
ALTER TABLE users_subscriptions DROP COLUMN expires;