forked from canonical/iot-identity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
organization_sql.go
50 lines (43 loc) · 1.59 KB
/
organization_sql.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// -*- Mode: Go; indent-tabs-mode: t -*-
/*
* This file is part of the IoT Identity Service
* Copyright 2019 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License version 3, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package postgres
const createOrganizationTableSQL string = `
CREATE TABLE IF NOT EXISTS organization (
id serial primary key not null,
org_id varchar(200) not null unique,
name varchar(200) not null,
country_name varchar(200) default '',
root_cert text not null,
root_key text not null,
UNIQUE (org_id)
)
`
const createOrganizationSQL = `
insert into organization (org_id, name, country_name, root_cert, root_key)
values ($1,$2,$3,$4,$5) RETURNING id`
const listOrganizationSQL = `
select id, org_id, name, root_cert
from organization`
const getOrganizationSQL = `
select id, org_id, name, country_name, root_cert, root_key
from organization
where org_id=$1`
const getOrganizationByNameSQL = `
select id, org_id, name, country_name, root_cert, root_key
from organization
where name=$1`