36 lines
1.1 KiB
Markdown
36 lines
1.1 KiB
Markdown
# Postgres
|
|
- url
|
|
- Format: `postgres://user@host:port/dbname` or `postgres:///dbname?host=/var/run/postgresql`.
|
|
- Default: `postgres://nxcaldav@localhost:5432/nxcaldav?sslmode=disable`
|
|
|
|
# Users
|
|
|
|
- name: required
|
|
- password: cleartext or bcrypt hash
|
|
- password_cmd: shell command
|
|
# password_cmd: "echo secretpassword" # Command (output will be hashed in DB)
|
|
# password: "$2y$12$LU.8xNK6m98hEJ5oRnBsDuMamfIjXoWTW0eMIJ6yGdLoP3nJAHWH6"
|
|
|
|
# SQL
|
|
## delte user
|
|
```sql
|
|
DELETE FROM users WHERE name = 'bob';
|
|
```
|
|
|
|
## delete calendar
|
|
```sql
|
|
DELETE FROM calendars WHERE name = 'bob_calendar' AND owner_id = (SELECT id FROM users WHERE name = 'bob');
|
|
/* or */
|
|
DELETE FROM calendars WHERE path = '/bob/calendars/old/';
|
|
```
|
|
## rename calendar
|
|
```sql
|
|
UPDATE calendars SET name = 'new', path '/bob/calendars/new/' WHERE path = '/bob/calendars/old/';
|
|
UPDATE calendar_objects SET path = regexp_replace(path, '/old/', '/new/')' WHERE your_column ~ '/sport/';
|
|
```
|
|
|
|
## Match Value in calendar objects
|
|
```sql
|
|
select id, path, linecut from calendar_objects, LATERAL regexp_split_to_table(data, E'\r\n') AS linecut where linecut ~ 'CLASS';
|
|
```
|