From 9f04bbd4265ac8d2dd134d869a3e9803ef314d59 Mon Sep 17 00:00:00 2001 From: Emmie Maeda Date: Fri, 12 Jan 2024 22:07:27 -0500 Subject: [PATCH] Set up yoyo migrations system. --- README.md | 6 ++++++ migrations/20240112_01_Njk7j-site.sql | 12 ++++++++++++ requirements.txt | 1 + yoyo.ini | 5 +++++ 4 files changed, 24 insertions(+) create mode 100644 migrations/20240112_01_Njk7j-site.sql create mode 100644 yoyo.ini diff --git a/README.md b/README.md index fc1fc1a..fc59067 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,12 @@ A new comprehensive backup system for Wikidot, maintained by the SCP-EN Technica This program is written for Python 3.11 or later. You will need a Wikidot API key, which you can get if you have a [Pro Plan](https://www.wikidot.com/plans). +### Configuration + +The `.env` file is sourced by the process to pull in secrets. Look at `.env.example` for the expected structure of this file. These secrets can also be set in the environment directly. + +Within `yoyo.ini`, override the database URL with the value of `$POSTGRES_DATABASE_URL`. + ### Setup Create a Python virtual environment, and then install this project's dependencies: diff --git a/migrations/20240112_01_Njk7j-site.sql b/migrations/20240112_01_Njk7j-site.sql new file mode 100644 index 0000000..febd510 --- /dev/null +++ b/migrations/20240112_01_Njk7j-site.sql @@ -0,0 +1,12 @@ +-- Create initial tables. +-- depends: + +CREATE TABLE site ( + slug TEXT PRIMARY KEY, + wikidot_id INTEGER NOT NULL, + home_slug TEXT NOT NULL, + domain TEXT NOT NULL, + language TEXT NOT NULL, + + UNIQUE (wikidot_id) +); diff --git a/requirements.txt b/requirements.txt index 795c567..e3eceb4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,3 +4,4 @@ pugsql>=0.2.4 python-dotenv>=1.0 requests>=2.31 types-requests>=2.31.0.0 +yoyo-migrations>=8.0 diff --git a/yoyo.ini b/yoyo.ini new file mode 100644 index 0000000..fe1b4da --- /dev/null +++ b/yoyo.ini @@ -0,0 +1,5 @@ +[DEFAULT] +sources = migrations +database = postgres://localhost +batch_mode = off +verbosity = 0