feat: create UserSubscription

This commit is contained in:
Zamitto
2024-10-15 22:40:47 -03:00
parent 8ff925fbb9
commit fe681c3af9
15 changed files with 147 additions and 17 deletions

View File

@@ -0,0 +1,27 @@
import type { HydraMigration } from "@main/knex-client";
import type { Knex } from "knex";
export const CreateUserSubscription: HydraMigration = {
name: "CreateUserSubscription",
up: async (knex: Knex) => {
return knex.schema.createTable("user_subscription", (table) => {
table.increments("id").primary();
table.string("subscriptionId").defaultTo("");
table
.text("userId")
.notNullable()
.references("user_auth.id")
.onDelete("CASCADE");
table.string("status").defaultTo("");
table.string("planId").defaultTo("");
table.string("planName").defaultTo("");
table.dateTime("expiresAt").nullable();
table.dateTime("createdAt").defaultTo(knex.fn.now());
table.dateTime("updatedAt").defaultTo(knex.fn.now());
});
},
down: async (knex: Knex) => {
return knex.schema.dropTable("user_subscription");
},
};

View File

@@ -3,8 +3,8 @@ import type { Knex } from "knex";
export const MigrationName: HydraMigration = {
name: "MigrationName",
up: async (knex: Knex) => {
await knex.schema.createTable("table_name", (table) => {});
up: (knex: Knex) => {
return knex.schema.createTable("table_name", async (table) => {});
},
down: async (knex: Knex) => {},