mirror of
https://github.com/stackblitz/bolt.new
synced 2025-06-26 18:17:50 +00:00
db
This commit is contained in:
parent
e5651604ec
commit
f9368b7481
@ -0,0 +1,17 @@
|
||||
export function up(knex) {
|
||||
return knex.schema.createTable('subscription_plans', function(table) {
|
||||
table.increments('_id').primary().comment('主键ID');
|
||||
table.string('name', 50).notNullable().unique().comment('计划名称');
|
||||
table.integer('tokens').unsigned().notNullable().comment('代币数量');
|
||||
table.decimal('price', 10, 2).notNullable().comment('月度价格');
|
||||
table.text('description').comment('计划描述');
|
||||
table.integer('save_percentage').unsigned().comment('节省百分比');
|
||||
table.boolean('is_active').defaultTo(true).comment('是否激活');
|
||||
table.timestamp('_create').defaultTo(knex.fn.now()).comment('创建时间');
|
||||
table.timestamp('_update').defaultTo(knex.fn.now()).comment('更新时间');
|
||||
});
|
||||
}
|
||||
|
||||
export function down(knex) {
|
||||
return knex.schema.dropTable('subscription_plans');
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
export function up(knex) {
|
||||
return knex('subscription_plans').insert([
|
||||
{
|
||||
name: 'Pro',
|
||||
tokens: 10000000,
|
||||
price: 20.00,
|
||||
description: '适合业余爱好者和轻度探索性使用的休闲用户。',
|
||||
save_percentage: null,
|
||||
},
|
||||
{
|
||||
name: 'Pro 50',
|
||||
tokens: 26000000,
|
||||
price: 50.00,
|
||||
description: '为每周需要使用多八多几次的专业人士设计。',
|
||||
save_percentage: 3,
|
||||
},
|
||||
{
|
||||
name: 'Pro 100',
|
||||
tokens: 55000000,
|
||||
price: 100.00,
|
||||
description: '完美适合希望提升日常工作流程的重度用户。',
|
||||
save_percentage: 9,
|
||||
},
|
||||
{
|
||||
name: 'Pro 200',
|
||||
tokens: 120000000,
|
||||
price: 200.00,
|
||||
description: '最适合依赖多八多作为核心工具持续使用的超级用户。',
|
||||
save_percentage: 17,
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
export function down(knex) {
|
||||
return knex('subscription_plans').del();
|
||||
}
|
||||
16
db/migrations/20241022093004_create_token_reloads_table.js
Normal file
16
db/migrations/20241022093004_create_token_reloads_table.js
Normal file
@ -0,0 +1,16 @@
|
||||
export function up(knex) {
|
||||
return knex.schema.createTable('token_reloads', function(table) {
|
||||
table.increments('_id').primary().comment('主键ID');
|
||||
table.string('name', 50).notNullable().unique().comment('充值包名称');
|
||||
table.integer('tokens').unsigned().notNullable().comment('代币数量');
|
||||
table.decimal('price', 10, 2).notNullable().comment('价格');
|
||||
table.text('description').comment('描述');
|
||||
table.boolean('is_active').defaultTo(true).comment('是否激活');
|
||||
table.timestamp('_create').defaultTo(knex.fn.now()).comment('创建时间');
|
||||
table.timestamp('_update').defaultTo(knex.fn.now()).comment('更新时间');
|
||||
});
|
||||
}
|
||||
|
||||
export function down(knex) {
|
||||
return knex.schema.dropTable('token_reloads');
|
||||
}
|
||||
14
db/migrations/20241022093005_insert_initial_token_reload.js
Normal file
14
db/migrations/20241022093005_insert_initial_token_reload.js
Normal file
@ -0,0 +1,14 @@
|
||||
export function up(knex) {
|
||||
return knex('token_reloads').insert([
|
||||
{
|
||||
name: '代币充值',
|
||||
tokens: 10000000,
|
||||
price: 20.00,
|
||||
description: '非订阅代币购买,每次充值10,000,000代币',
|
||||
}
|
||||
]);
|
||||
}
|
||||
|
||||
export function down(knex) {
|
||||
return knex('token_reloads').del();
|
||||
}
|
||||
19
db/migrations/20241022093006_create_chat_histories_table.js
Normal file
19
db/migrations/20241022093006_create_chat_histories_table.js
Normal file
@ -0,0 +1,19 @@
|
||||
export function up(knex) {
|
||||
return knex.schema.createTable('chat_histories', function(table) {
|
||||
table.increments('_id').primary().comment('主键ID');
|
||||
table.integer('user_id').unsigned().notNullable().comment('用户ID');
|
||||
table.foreign('user_id').references('users._id').onDelete('CASCADE');
|
||||
table.text('message').notNullable().comment('消息内容');
|
||||
table.enum('role', ['user', 'assistant']).notNullable().comment('消息角色');
|
||||
table.integer('tokens_used').unsigned().comment('使用的代币数量');
|
||||
table.string('session_id', 255).comment('会话ID');
|
||||
table.timestamp('_create').defaultTo(knex.fn.now()).comment('创建时间');
|
||||
table.timestamp('_update').defaultTo(knex.fn.now()).comment('更新时间');
|
||||
table.index('user_id');
|
||||
table.index('session_id');
|
||||
});
|
||||
}
|
||||
|
||||
export function down(knex) {
|
||||
return knex.schema.dropTable('chat_histories');
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user