fix: add revised migration
All checks were successful
Update changelog / changelog (push) Successful in 25s
All checks were successful
Update changelog / changelog (push) Successful in 25s
This commit is contained in:
@@ -12,10 +12,11 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
container: docker.io/thegeeklab/git-sv:2.0.9
|
||||
steps:
|
||||
- name: install tools
|
||||
- name: Install tools
|
||||
run: |
|
||||
apk add -q --update --no-cache nodejs
|
||||
- uses: actions/checkout@v6
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-tags: true
|
||||
fetch-depth: 0
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class InitialMigration1764549652720 implements MigrationInterface {
|
||||
name = 'InitialMigration1764549652720'
|
||||
export class RevisedMigration1765488793696 implements MigrationInterface {
|
||||
name = 'RevisedMigration1765488793696'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
@@ -10,9 +10,10 @@ export class InitialMigration1764549652720 implements MigrationInterface {
|
||||
"subdomain" character varying,
|
||||
"shortUri" character varying NOT NULL,
|
||||
"fullUrl" character varying NOT NULL,
|
||||
"role" character varying NOT NULL,
|
||||
"createDate" bigint NOT NULL,
|
||||
"expiryDate" bigint NOT NULL,
|
||||
"expiryDate" bigint,
|
||||
"visits" bigint NOT NULL,
|
||||
"privacy" boolean NOT NULL,
|
||||
"authorId" integer,
|
||||
CONSTRAINT "PK_ecf17f4a741d3c5ba0b4c5ab4b6" PRIMARY KEY ("id")
|
||||
)
|
||||
@@ -22,7 +23,7 @@ export class InitialMigration1764549652720 implements MigrationInterface {
|
||||
"id" SERIAL NOT NULL,
|
||||
"name" character varying NOT NULL,
|
||||
"passwordHash" character varying NOT NULL,
|
||||
"role" character varying NOT NULL,
|
||||
"role" integer NOT NULL,
|
||||
"createdAt" bigint NOT NULL,
|
||||
CONSTRAINT "UQ_51b8b26ac168fbe7d6f5653e6cf" UNIQUE ("name"),
|
||||
CONSTRAINT "PK_a3ffb1c0c8416b9fc6f907b7433" PRIMARY KEY ("id")
|
||||
@@ -4,27 +4,44 @@ import { User } from "./User"
|
||||
@Entity("links")
|
||||
export class Link {
|
||||
|
||||
// Unique link id.
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number
|
||||
|
||||
// Experimental: subdomain which should be a part of the short url.
|
||||
// For instance in the URL "abc.example.com/def", abc is the subdomain.
|
||||
// "def.example.com/def" won't resolve to the URL that "abc.example.com/def" does.
|
||||
@Column({ nullable: true })
|
||||
subdomain: string | null
|
||||
|
||||
// Shortened Uri.
|
||||
@Column()
|
||||
shortUri: string
|
||||
|
||||
// URL to which the user should be redirected
|
||||
@Column()
|
||||
fullUrl: string
|
||||
|
||||
@Column()
|
||||
role: string
|
||||
|
||||
// Unix timestamp of link creation date.
|
||||
@Column('bigint')
|
||||
createDate: number
|
||||
|
||||
@Column('bigint')
|
||||
expiryDate: number
|
||||
// Unix timestamp of when the link should expire.
|
||||
// If null, the link will never expire unless deleted.
|
||||
@Column('bigint', { nullable: true })
|
||||
expiryDate: number | null
|
||||
|
||||
// Aggregated amount of visits.
|
||||
@Column('bigint')
|
||||
visits: number
|
||||
|
||||
// Link privacy:
|
||||
// - true, if link is private
|
||||
// - false, if link can be shown in a list of recent links publicly.
|
||||
@Column()
|
||||
privacy: boolean
|
||||
|
||||
// User to which the shortened URL belongs.
|
||||
@ManyToOne(() => User, (user) => user.links, { nullable: true })
|
||||
@JoinTable()
|
||||
author: User | null
|
||||
|
||||
@@ -4,21 +4,29 @@ import { Link } from "./Link"
|
||||
@Entity("users")
|
||||
export class User {
|
||||
|
||||
// Unique user id.
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number
|
||||
|
||||
// User name, must be unique.
|
||||
@Column({ unique: true })
|
||||
name: string
|
||||
|
||||
// Salted password hash.
|
||||
@Column()
|
||||
passwordHash: string
|
||||
|
||||
// User role:
|
||||
// - 0 - means unprivileged user,
|
||||
// - 1 - means administrative user.
|
||||
@Column()
|
||||
role: string
|
||||
role: number
|
||||
|
||||
// Account creation date as a Unix timestamp.
|
||||
@Column('bigint')
|
||||
createdAt: number
|
||||
|
||||
// List of shortened URLs which belong to the user.
|
||||
@OneToMany(() => Link, (link) => link.author)
|
||||
links: Link[];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user