From ff33fd7bcffe592355dc2131b8916a30d2453d6a Mon Sep 17 00:00:00 2001 From: Bastard Operator Date: Fri, 26 Nov 2021 01:02:27 +0100 Subject: [PATCH] Join things together to postgres --- .gitignore | 1 + config/config.php.example | 7 ++++++- migrations/00001-create-users-table.sql | 8 ++++++++ src/action/oauth/mastodon.php | 1 + src/classes/database.php | 15 +++++++++++++++ 5 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 migrations/00001-create-users-table.sql create mode 100644 src/classes/database.php diff --git a/.gitignore b/.gitignore index 4a9937a..569a1be 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .*.swp *.mock config/config.php +migrations/*.done diff --git a/config/config.php.example b/config/config.php.example index 73948cb..2b45788 100644 --- a/config/config.php.example +++ b/config/config.php.example @@ -1,5 +1,10 @@ "https://your-site.com", + "db_host" => "127.0.0.1", + "db_port" => 5432, + "db_name" => "realfan", + "db_user" => "realfan", + "db_pass" => "changemeNOW", + "site_name" => "https://your-site.com", ]; diff --git a/migrations/00001-create-users-table.sql b/migrations/00001-create-users-table.sql new file mode 100644 index 0000000..73ff43a --- /dev/null +++ b/migrations/00001-create-users-table.sql @@ -0,0 +1,8 @@ +CREATE TABLE IF NOT EXISTS users ( + id serial PRIMARY KEY, + acct VARCHAR(64) UNIQUE NOT NULL, + access_token VARCHAR(128) NOT NULL, + account_data TEXT NULL, + account_type VARCHAR(32) NOT NULL, + created_on TIMESTAMP NOT NULL +); diff --git a/src/action/oauth/mastodon.php b/src/action/oauth/mastodon.php index 899dc3c..936e664 100644 --- a/src/action/oauth/mastodon.php +++ b/src/action/oauth/mastodon.php @@ -1,3 +1,4 @@ + db = new PDO('pgsql:host=db;dbname=realfan', 'realfan', 'changemeNOW'); + } + + public function close() { + $this->db->close(); + } + +}