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

add SQL CREATE TABLE queries for PostgreSQL #1148

Merged
merged 1 commit into from
Jun 27, 2023
Merged
Changes from all commits
Commits
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
62 changes: 62 additions & 0 deletions src/rest.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,19 @@
| PRIMARY KEY (`id`)
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
| For PostgreSQL
| CREATE TABLE keys (
| id SERIAL,
| user_id INT NOT NULL,
| key VARCHAR(40) NOT NULL,
| level INT NOT NULL,
| ignore_limits SMALLINT NOT NULL DEFAULT '0',
| is_private_key SMALLINT NOT NULL DEFAULT '0',
| ip_addresses TEXT NULL DEFAULT NULL,
| date_created INT NOT NULL,
| PRIMARY KEY (id)
| ) ;
| |
*/
$config['rest_enable_keys'] = false;

Expand Down Expand Up @@ -402,6 +415,20 @@
| PRIMARY KEY (`id`)
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
| For PostgreSQL
| CREATE TABLE logs (
| id SERIAL,
| uri VARCHAR(255) NOT NULL,
| method VARCHAR(6) NOT NULL,
| params TEXT DEFAULT NULL,
| api_key VARCHAR(40) NOT NULL,
| ip_address VARCHAR(45) NOT NULL,
| time INT NOT NULL,
| rtime DOUBLE PRECISION DEFAULT NULL,
| authorized boolean NOT NULL,
| response_code smallint DEFAULT '0',
| PRIMARY KEY (id)
| ) ;
*/
$config['rest_enable_logging'] = false;

Expand Down Expand Up @@ -435,6 +462,31 @@
| PRIMARY KEY (`id`)
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
| For PostgreSQL
| CREATE TABLE access (
| id SERIAL,
| key VARCHAR(40) NOT NULL DEFAULT '',
| all_access SMALLINT NOT NULL DEFAULT '0',
| controller VARCHAR(50) NOT NULL DEFAULT '',
| date_created TIMESTAMP(0) DEFAULT NULL,
| date_modified TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP,
| PRIMARY KEY (id)
| ) ;
| CREATE OR REPLACE FUNCTION upd_timestamp() RETURNS TRIGGER
| LANGUAGE plpgsql
| AS
| $$
| BEGIN
| NEW.modified = CURRENT_TIMESTAMP;
| RETURN NEW;
| END;
| $$;
| CREATE TRIGGER trigger_access
| BEFORE UPDATE
| ON access
| FOR EACH ROW
| EXECUTE PROCEDURE upd_timestamp();
|
*/
$config['rest_enable_access'] = false;

Expand Down Expand Up @@ -479,6 +531,16 @@
| PRIMARY KEY (`id`)
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
| For PostgreSQL
| CREATE TABLE limits (
| id SERIAL,
| uri VARCHAR(255) NOT NULL,
| count INT NOT NULL,
| hour_started INT NOT NULL,
| api_key VARCHAR(40) NOT NULL,
| PRIMARY KEY (id)
| ) ;
|
| To specify the limits within the controller's __construct() method, add per-method
| limits with:
|
Expand Down