@ductape/cli 0.2.8 → 0.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,9 +6,9 @@ import { fail, printJson } from '../lib/output.js';
6
6
  function buildDbContext(dbTag, envSlug, productTag) {
7
7
  return { database: dbTag, env: envSlug, product: productTag };
8
8
  }
9
- async function getAppliedTags(proxy, dbContext, productTag, envSlug) {
9
+ async function getAppliedTags(proxy, dbContext) {
10
10
  try {
11
- const result = await proxy.execute('migration.list', [{ product: productTag, env: envSlug, database: dbContext.database }], dbContext);
11
+ const result = await proxy.execute('migration.history', [], dbContext);
12
12
  const list = Array.isArray(result)
13
13
  ? result
14
14
  : Array.isArray(result.data)
@@ -44,7 +44,7 @@ export async function runDbMigrate(opts) {
44
44
  console.log(`[${db}] No migration files found. Run \`ductape db schema generate\` first.`);
45
45
  continue;
46
46
  }
47
- const appliedTags = await getAppliedTags(proxy, dbContext, productTag, envSlug);
47
+ const appliedTags = await getAppliedTags(proxy, dbContext);
48
48
  const pending = migrations.filter((m) => !appliedTags.includes(m.tag));
49
49
  if (pending.length === 0) {
50
50
  console.log(`[${db}] Already up to date.`);
@@ -59,7 +59,7 @@ export async function runDbMigrate(opts) {
59
59
  }
60
60
  process.stdout.write(` Applying ${migration.tag}... `);
61
61
  try {
62
- await proxy.execute('migration.run', [{ product: productTag, env: envSlug, database: db, migrations: [migration] }], dbContext);
62
+ await proxy.execute('migration.run', [[migration]], dbContext);
63
63
  console.log('done');
64
64
  totalApplied++;
65
65
  }
@@ -92,7 +92,7 @@ export async function runDbMigrateStatus(opts) {
92
92
  const { db } = entry;
93
93
  const dbContext = buildDbContext(db, envSlug, productTag);
94
94
  const migrations = loadMigrationFiles(dir, db);
95
- const appliedTags = await getAppliedTags(proxy, dbContext, productTag, envSlug);
95
+ const appliedTags = await getAppliedTags(proxy, dbContext);
96
96
  const applied = migrations.filter((m) => appliedTags.includes(m.tag)).map((m) => m.tag);
97
97
  const pending = migrations.filter((m) => !appliedTags.includes(m.tag)).map((m) => m.tag);
98
98
  statusReport[db] = { applied, pending };
@@ -132,7 +132,7 @@ export async function runDbMigrateRollback(opts) {
132
132
  const { db } = entry;
133
133
  const dbContext = buildDbContext(db, envSlug, productTag);
134
134
  const migrations = loadMigrationFiles(dir, db);
135
- const appliedTags = await getAppliedTags(proxy, dbContext, productTag, envSlug);
135
+ const appliedTags = await getAppliedTags(proxy, dbContext);
136
136
  const applied = migrations.filter((m) => appliedTags.includes(m.tag));
137
137
  const toRollback = applied.slice(-rollbackCount).reverse();
138
138
  if (toRollback.length === 0) {
@@ -142,7 +142,7 @@ export async function runDbMigrateRollback(opts) {
142
142
  for (const migration of toRollback) {
143
143
  process.stdout.write(` Rolling back ${migration.tag}... `);
144
144
  try {
145
- await proxy.execute('migration.rollback', [{ product: productTag, env: envSlug, database: db, migrations: [migration] }], dbContext);
145
+ await proxy.execute('migration.rollback', [[migration], 1], dbContext);
146
146
  console.log('done');
147
147
  }
148
148
  catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ductape/cli",
3
- "version": "0.2.8",
3
+ "version": "0.2.10",
4
4
  "description": "Ductape CLI — local platform, login, link projects, and manage resources via the proxy (Workbench-compatible)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -30,13 +30,11 @@ function buildDbContext(dbTag: string, envSlug: string, productTag: string): Dat
30
30
  async function getAppliedTags(
31
31
  proxy: ReturnType<typeof getDbProxy>,
32
32
  dbContext: DatabaseContext,
33
- productTag: string,
34
- envSlug: string,
35
33
  ): Promise<string[]> {
36
34
  try {
37
35
  const result = await proxy.execute<unknown>(
38
- 'migration.list',
39
- [{ product: productTag, env: envSlug, database: dbContext.database }],
36
+ 'migration.history',
37
+ [],
40
38
  dbContext,
41
39
  );
42
40
  const list = Array.isArray(result)
@@ -80,7 +78,7 @@ export async function runDbMigrate(opts: MigrateOpts): Promise<void> {
80
78
  continue;
81
79
  }
82
80
 
83
- const appliedTags = await getAppliedTags(proxy, dbContext, productTag, envSlug);
81
+ const appliedTags = await getAppliedTags(proxy, dbContext);
84
82
  const pending = migrations.filter((m) => !appliedTags.includes(m.tag));
85
83
 
86
84
  if (pending.length === 0) {
@@ -101,7 +99,7 @@ export async function runDbMigrate(opts: MigrateOpts): Promise<void> {
101
99
  try {
102
100
  await proxy.execute(
103
101
  'migration.run',
104
- [{ product: productTag, env: envSlug, database: db, migrations: [migration] }],
102
+ [[migration]],
105
103
  dbContext,
106
104
  );
107
105
  console.log('done');
@@ -139,7 +137,7 @@ export async function runDbMigrateStatus(opts: MigrateStatusOpts): Promise<void>
139
137
  const { db } = entry;
140
138
  const dbContext = buildDbContext(db, envSlug, productTag);
141
139
  const migrations = loadMigrationFiles(dir, db);
142
- const appliedTags = await getAppliedTags(proxy, dbContext, productTag, envSlug);
140
+ const appliedTags = await getAppliedTags(proxy, dbContext);
143
141
 
144
142
  const applied = migrations.filter((m) => appliedTags.includes(m.tag)).map((m) => m.tag);
145
143
  const pending = migrations.filter((m) => !appliedTags.includes(m.tag)).map((m) => m.tag);
@@ -183,7 +181,7 @@ export async function runDbMigrateRollback(opts: MigrateRollbackOpts): Promise<v
183
181
  const { db } = entry;
184
182
  const dbContext = buildDbContext(db, envSlug, productTag);
185
183
  const migrations = loadMigrationFiles(dir, db);
186
- const appliedTags = await getAppliedTags(proxy, dbContext, productTag, envSlug);
184
+ const appliedTags = await getAppliedTags(proxy, dbContext);
187
185
 
188
186
  const applied = migrations.filter((m) => appliedTags.includes(m.tag));
189
187
  const toRollback = applied.slice(-rollbackCount).reverse();
@@ -198,7 +196,7 @@ export async function runDbMigrateRollback(opts: MigrateRollbackOpts): Promise<v
198
196
  try {
199
197
  await proxy.execute(
200
198
  'migration.rollback',
201
- [{ product: productTag, env: envSlug, database: db, migrations: [migration] }],
199
+ [[migration], 1],
202
200
  dbContext,
203
201
  );
204
202
  console.log('done');