Switch Friends to nex-go-rewrite branch

This commit is contained in:
Matthew Lopez 2024-06-26 16:13:10 -04:00
parent 8ab28e8eaa
commit bf8ae18400
No known key found for this signature in database
GPG Key ID: 302A6EE3D63B7E0E
6 changed files with 65 additions and 6 deletions

2
.gitmodules vendored
View File

@ -24,7 +24,7 @@ ignore = dirty
[submodule "repos/friends"]
path = repos/friends
url = https://github.com/PretendoNetwork/friends.git
branch = dev
branch = nex-go-rewrite
ignore = dirty
[submodule "repos/miiverse-api"]

@ -1 +1 @@
Subproject commit cc9b839d45bf7b65203c9d74935ad927aa8e8b49
Subproject commit ee46ec47e5d5549bb68f45c5e130b69409f0688b

18
scripts/internal/migrations.sh Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/env bash
# shellcheck source=./framework.sh
source "$(dirname "$(realpath "$0")")/framework.sh"
parse_arguments "$@"
print_info "Running migrations..."
load_dotenv postgres.env postgres.local.env
# Migrate friends to the nex-go rewrite
migration=$(cat "$git_base_dir/scripts/run-in-container/friends-nex-go-rewrite-migration.sql")
compose_no_progress up -d friends
# shellcheck disable=SC2046
docker compose exec postgres psql -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" -d friends -c "$migration" $(if_not_verbose --quiet)
print_success "Migrations are complete."

View File

@ -0,0 +1,39 @@
-- See https://github.com/PretendoNetwork/friends/pull/15
ALTER TABLE "3ds".user_data
ADD IF NOT EXISTS country integer DEFAULT 0,
ALTER COLUMN comment SET DEFAULT '',
ALTER COLUMN comment_changed SET DEFAULT 0,
ALTER COLUMN last_online SET DEFAULT 0,
ALTER COLUMN favorite_title SET DEFAULT 0,
ALTER COLUMN favorite_title_version SET DEFAULT 0,
ALTER COLUMN mii_name SET DEFAULT '',
ALTER COLUMN mii_data SET DEFAULT '',
ALTER COLUMN mii_changed SET DEFAULT 0,
ALTER COLUMN region SET DEFAULT 0,
ALTER COLUMN area SET DEFAULT 0,
ALTER COLUMN language SET DEFAULT 0;
UPDATE "3ds".user_data SET comment = '' WHERE comment IS NULL;
UPDATE "3ds".user_data SET comment_changed = 0 WHERE comment_changed IS NULL;
UPDATE "3ds".user_data SET last_online = 0 WHERE last_online IS NULL;
UPDATE "3ds".user_data SET favorite_title = 0 WHERE favorite_title IS NULL;
UPDATE "3ds".user_data SET favorite_title_version = 0 WHERE favorite_title_version IS NULL;
UPDATE "3ds".user_data SET mii_name = '' WHERE mii_name IS NULL;
UPDATE "3ds".user_data SET mii_data = '' WHERE mii_data IS NULL;
UPDATE "3ds".user_data SET mii_changed = 0 WHERE mii_changed IS NULL;
UPDATE "3ds".user_data SET region = 0 WHERE region IS NULL;
UPDATE "3ds".user_data SET area = 0 WHERE area IS NULL;
UPDATE "3ds".user_data SET language = 0 WHERE language IS NULL;
ALTER TABLE wiiu.user_data
ALTER COLUMN last_online SET DEFAULT 0;
UPDATE wiiu.user_data SET last_online = 0 WHERE last_online IS NULL;
-- See https://github.com/PretendoNetwork/friends/pull/19
ALTER TABLE "3ds".user_data
ADD IF NOT EXISTS mii_profanity boolean DEFAULT FALSE,
ADD IF NOT EXISTS mii_character_set integer DEFAULT 0;
UPDATE "3ds".user_data SET mii_profanity = FALSE WHERE mii_profanity IS NULL;
UPDATE "3ds".user_data SET mii_character_set = 0 WHERE mii_character_set IS NULL;

View File

@ -93,10 +93,11 @@ echo "POSTGRES_PASSWORD=$postgres_password" >>./postgres.local.env
echo "PN_FRIENDS_CONFIG_DATABASE_URI=postgres://postgres_pretendo:$postgres_password@postgres/friends?sslmode=disable" >>./friends.local.env
echo "PN_SMM_POSTGRES_URI=postgres://postgres_pretendo:$postgres_password@postgres/super_mario_maker?sslmode=disable" >>./super-mario-maker.local.env
# Generate a Kerberos password, a gRPC API key, and an AES key for the friends
# server
friends_kerberos_password=$(generate_password 32)
echo "PN_FRIENDS_CONFIG_KERBEROS_PASSWORD=$friends_kerberos_password" >>./friends.local.env
# Generate passwords, a gRPC API key, and an AES key for the friends server
friends_authentication_password=$(generate_password 32)
echo "PN_FRIENDS_CONFIG_AUTHENTICATION_PASSWORD=$friends_authentication_password" >>./friends.local.env
friends_secure_password=$(generate_password 32)
echo "PN_FRIENDS_CONFIG_SECURE_PASSWORD=$friends_secure_password" >>./friends.local.env
friends_api_key=$(generate_password 32)
echo "PN_FRIENDS_CONFIG_GRPC_API_KEY=$friends_api_key" >>./friends.local.env
echo "PN_WIIU_CHAT_FRIENDS_GRPC_API_KEY=$friends_api_key" >>./wiiu-chat.local.env

View File

@ -61,6 +61,7 @@ setup_containers() {
./scripts/internal/update-account-servers-database.sh
./scripts/internal/update-miiverse-endpoints.sh
./scripts/internal/update-postgres-password.sh
./scripts/internal/migrations.sh
print_info "Stopping containers after initial setup..."
compose_no_progress down
}