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

Prepare to migrate to the new versioning system - part 2 #66

Merged
merged 23 commits into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b01adb7
names table: foreign pointer key ON DELETE SET NULL
Digitalone1 Jan 19, 2023
688877b
post new package: check if a name is available before publication
Digitalone1 Jan 19, 2023
b93e0e2
check name availability also on rename
Digitalone1 Jan 19, 2023
95b2462
delete package: do not remove names
Digitalone1 Jan 19, 2023
38421a7
test package name availability
Digitalone1 Jan 19, 2023
cf83b4a
remove unneeded script for duplicated versions
Digitalone1 Jan 21, 2023
61e698d
revert database changes made in #42
Digitalone1 Jan 21, 2023
b89c8ec
add updated/created columns for versions table + update trigger
Digitalone1 Jan 21, 2023
f22d770
start to retrive the results without relying on status = latest
Digitalone1 Jan 21, 2023
ed8b507
more tests on sorting variants + move deletion tests at the end
Digitalone1 Jan 21, 2023
b69792a
add deleted bool column to versions table
Digitalone1 Jan 22, 2023
0e745a1
deprecate status enum in versions table
Digitalone1 Jan 22, 2023
c9acfa4
prepare to deprecate package.data in favour of versions.meta
Digitalone1 Jan 22, 2023
d67bedc
deprecate package.data + use structuredClone and fix tests
Digitalone1 Jan 24, 2023
c89e0d9
remove unused const as suggested by CodeQL
Digitalone1 Jan 24, 2023
51cf557
Upgrade Node Version
confused-Techie Jan 25, 2023
ec0deff
Removed `14` as supported version due to `??=` usage
confused-Techie Jan 25, 2023
ba1dba0
Add explicit support for Node 15
confused-Techie Jan 25, 2023
a81a7f4
Drop support for Node 15
confused-Techie Jan 25, 2023
957ea85
Merge remote-tracking branch 'upstream/upgrade-node' into new-version…
Digitalone1 Jan 25, 2023
3414640
struturedClone not supported for NodeJS v16
Digitalone1 Jan 25, 2023
97ad2bc
Bump minimum supported version to 17
confused-Techie Jan 27, 2023
5080b47
Merge remote branch 'upstream/upgrade-node' into new-versioning-system-2
Digitalone1 Jan 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

strategy:
matrix:
node-version: [16.x]
node-version: [18.x]

steps:
- name: Checkout the latest code
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-tests-pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:

strategy:
matrix:
node-version: [16.x]
node-version: [17.x, 18.x, 19.x]

steps:
- name: Checkout the latest code
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:

strategy:
matrix:
node-version: [16.x]
node-version: [17.x, 18.x, 19.x]

steps:
- name: Checkout the latest code
Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18
6 changes: 3 additions & 3 deletions app.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Name this file app.yaml, and it will be picked up by the server.
# app.yaml is in the git ignore to prevent any secrets from leaking.

runtime: nodejs14
runtime: nodejs18
service: default

env_variables:
Expand All @@ -22,8 +22,6 @@ env_variables:
GH_CLIENTID: ""
# The Client Secret to accompany the CLIENT ID
GH_CLIENTSECRET: ""
# The github username associated with the token.
GH_USERNAME: ""
# The User Agent thats used to communicate with GitHub
GH_USERAGENT: "Pulsar-Edit Bot"
# The URI that the OAuth instance should redirect to. Should end in `/api/oauth`
Expand All @@ -48,3 +46,5 @@ env_variables:
# Determines how Logs are written. Currently supports the following options:
# stdout - Writes the console
LOG_FORMAT: "stdout"
RATE_LIMIT_GENERIC: 300
RATE_LIMIT_AUTH: 300
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "The Pulsar API Backend for the Community fork of Atom.",
"main": "src/server.js",
"engines": {
"node": ">=14.0.0 <=16.16.0"
"node": ">=17.9.1 <=18.13.0"
},
"scripts": {
"start": "node ./src/server.js",
Expand Down
20 changes: 18 additions & 2 deletions scripts/database/create_names_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,26 @@

CREATE TABLE names (
name VARCHAR(128) NOT NULL PRIMARY KEY,
pointer UUID NOT NULL REFERENCES packages(pointer),
pointer UUID NULL,
-- constraints
CONSTRAINT lowercase_names CHECK (name = LOWER(name))
CONSTRAINT lowercase_names CHECK (name = LOWER(name)),
CONSTRAINT package_names_fkey FOREIGN KEY (pointer) REFERENCES packages(pointer) ON DELETE SET NULL
);

-- Lowercase constraint added upon the following issue:
-- https://github.com/confused-Techie/atom-backend/issues/90

/*
-- `pointer` was NOT NULL, then we made it nullable.
-- The previous foreign key has been dropped and a new `package_names_fkey`
-- has need added to avoid supply chain attacks.
-- `pointer` is set to NULL when a row in packages table is deleted.
-- Steps made to apply this change:

ALTER TABLE names ALTER COLUMN pointer DROP NOT NULL;

ALTER TABLE names DROP CONSTRAINT previous_foreign_key_name;

ALTER TABLE names
ADD CONSTRAINT package_names_fkey FOREIGN KEY (pointer) REFERENCES packages(pointer) ON DELETE SET NULL;
*/
15 changes: 14 additions & 1 deletion scripts/database/create_versions_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ CREATE TABLE versions (
semver VARCHAR(256) NOT NULL,
license VARCHAR(128) NOT NULL,
engine JSONB NOT NULL,
created TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
meta JSONB,
deleted BOOLEAN NOT NULL DEFAULT FALSE,
-- generated columns
semver_v1 INTEGER GENERATED ALWAYS AS
(CAST ((regexp_match(semver, '^(\d+)\.(\d+)\.(\d+)'))[1] AS INTEGER)) STORED,
Expand All @@ -21,5 +24,15 @@ CREATE TABLE versions (
(CAST ((regexp_match(semver, '^(\d+)\.(\d+)\.(\d+)'))[3] AS INTEGER)) STORED,
-- constraints
CONSTRAINT semver2_format CHECK (semver ~ '^\d+\.\d+\.\d+'),
CONSTRAINT unique_pack_version UNIQUE(package, semver_v1, semver_v2, semver_v3)
CONSTRAINT unique_pack_version UNIQUE(package, semver)
);

-- Create a function and a trigger to set the current timestamp
-- in the `updated` column of the updated row.
-- The function now_on_updated_package() is the same defined in
-- the script for the `packages` table.

CREATE TRIGGER trigger_now_on_updated_versions
BEFORE UPDATE ON versions
FOR EACH ROW
EXECUTE PROCEDURE now_on_updated_package();
86 changes: 0 additions & 86 deletions scripts/tools/duplicateVersions.js

This file was deleted.

Loading