Skip to content

Commit

Permalink
add SQL CREATE TABLE queries for PostgreSQL
Browse files Browse the repository at this point in the history
  • Loading branch information
tenzap authored and chriskacerguis committed Jun 27, 2023
1 parent a16bdd6 commit f36aa04
Showing 1 changed file with 62 additions and 0 deletions.
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

0 comments on commit f36aa04

Please sign in to comment.