-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #479 from openziti/vanity_share_tokens
Unique Names (Vanity Share Tokens) (#123)
- Loading branch information
Showing
58 changed files
with
747 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
controller/store/sql/postgresql/015_v0_4_19_share_unique_name_constraint.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-- +migrate Up | ||
|
||
-- remove the old unique index (which did not respect the deleted flag) | ||
ALTER TABLE shares DROP CONSTRAINT shares_token_key; | ||
|
||
-- add a new unique index which only constrains uniqueness for not-deleted rows | ||
CREATE UNIQUE INDEX shares_token_idx ON shares(token) WHERE deleted is false; |
55 changes: 55 additions & 0 deletions
55
controller/store/sql/sqlite3/015_v0_4_19_share_unique_name_constraint.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
-- +migrate Up | ||
|
||
alter table shares rename to shares_old; | ||
create table shares ( | ||
id integer primary key, | ||
environment_id integer constraint fk_environments_shares references environments on delete cascade, | ||
z_id string not null unique, | ||
token string not null, | ||
share_mode string not null, | ||
backend_mode string not null, | ||
frontend_selection string, | ||
frontend_endpoint string, | ||
backend_proxy_endpoint string, | ||
reserved boolean not null default(false), | ||
created_at datetime not null default(strftime('%Y-%m-%d %H:%M:%f', 'now')), | ||
updated_at datetime not null default(strftime('%Y-%m-%d %H:%M:%f', 'now')), deleted boolean not null default(false), | ||
|
||
constraint chk_z_id check (z_id <> ''), | ||
constraint chk_token check (token <> ''), | ||
constraint chk_share_mode check (share_mode == 'public' or share_mode == 'private'), | ||
constraint chk_backend_mode check (backend_mode == 'proxy' or backend_mode == 'web' or backend_mode == 'tcpTunnel' or backend_mode == 'udpTunnel' or backend_mode == 'caddy' or backend_mode == 'drive') | ||
); | ||
CREATE UNIQUE INDEX shares_token_idx ON shares(token) WHERE deleted is false; | ||
insert into shares select * from shares_old; | ||
drop table shares_old; | ||
|
||
alter table frontends rename to frontends_old; | ||
create table frontends ( | ||
id integer primary key, | ||
environment_id integer references environments(id), | ||
token varchar(32) not null unique, | ||
z_id varchar(32) not null, | ||
public_name varchar(64) unique, | ||
url_template varchar(1024), | ||
reserved boolean not null default(false), | ||
created_at datetime not null default(strftime('%Y-%m-%d %H:%M:%f', 'now')), | ||
updated_at datetime not null default(strftime('%Y-%m-%d %H:%M:%f', 'now')), | ||
deleted boolean not null default(false), | ||
private_share_id integer references shares(id) | ||
); | ||
insert into frontends select * from frontends_old; | ||
drop table frontends_old; | ||
|
||
alter table share_limit_journal rename to share_limit_journal_old; | ||
create table share_limit_journal ( | ||
id integer primary key, | ||
share_id integer references shares(id), | ||
rx_bytes bigint not null, | ||
tx_bytes bigint not null, | ||
action limit_action_type not null, | ||
created_at datetime not null default(strftime('%Y-%m-%d %H:%M:%f', 'now')), | ||
updated_at datetime not null default(strftime('%Y-%m-%d %H:%M:%f', 'now')) | ||
); | ||
insert into share_limit_journal select * from share_limit_journal_old; | ||
drop table share_limit_journal_old; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.