u8views / go-u8views

GitHub-profile views tracker: displaying monthly view statistics
https://u8views.com
MIT License
449 stars 6 forks source link

Redirect to new username. #30

Closed IraIvanishak closed 3 months ago

IraIvanishak commented 4 months ago

Description https://github.com/u8views/go-u8views/issues/28

YaroslavPodorvanov commented 4 months ago
-- +goose Up
-- +goose StatementBegin
CREATE TABLE username_redirects
(
    id                 BIGSERIAL       NOT NULL PRIMARY KEY,
    user_id            BIGINT          NOT NULL REFERENCES users (id),
    social_provider    SOCIAL_PROVIDER NOT NULL,
    canonical_username VARCHAR         NOT NULL,
    UNIQUE (canonical_username, social_provider)
);

CREATE TABLE username_history
(
    id                 BIGSERIAL       NOT NULL PRIMARY KEY,
    user_id            BIGINT          NOT NULL REFERENCES users (id),
    social_provider    SOCIAL_PROVIDER NOT NULL,
    canonical_username VARCHAR         NOT NULL,
    created_at         TIMESTAMP       NOT NULL,
    updated_at         TIMESTAMP       NOT NULL,
    UNIQUE (canonical_username, social_provider, user_id)
);
-- +goose StatementEnd

-- +goose Down
-- +goose StatementBegin
DROP TABLE username_history;
DROP TABLE username_redirects;
-- +goose StatementEnd