sonamu 0.0.20 → 0.0.21

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.
@@ -21,7 +21,7 @@ export class Template__smd extends Template {
21
21
  return {
22
22
  ...this.getTargetAndPath(names),
23
23
  body: `
24
- import { p, SMDInput } from "sonamu";
24
+ import { p, i, SMDInput } from "sonamu";
25
25
  import { ${smdId}FieldExpr } from "./${names.fs}.generated";
26
26
 
27
27
  /*
@@ -37,6 +37,10 @@ export const ${names.camel}SmdInput: SMDInput<${smdId}FieldExpr> = {
37
37
  now: true,
38
38
  }),
39
39
  ],
40
+ indexes: [
41
+ i.index('created_at'),
42
+ //
43
+ ],
40
44
  subsets: {
41
45
  A: [ 'id', 'created_at' ]
42
46
  }
@@ -122,8 +122,6 @@ type _RelationProp = {
122
122
  name: string;
123
123
  with: string;
124
124
  nullable?: boolean;
125
- index?: true | string[];
126
- unique?: true | string[];
127
125
  toFilter?: true;
128
126
  };
129
127
  export type OneToOneRelationProp = _RelationProp & {
@@ -180,12 +178,19 @@ export type SMDProp =
180
178
  | VirtualProp
181
179
  | RelationProp;
182
180
 
181
+ export type SMDIndex = {
182
+ type: "index" | "unique";
183
+ columns: string[];
184
+ name?: string;
185
+ };
186
+
183
187
  export type SMDInput<T extends string> = {
184
188
  id: string;
185
189
  parentId?: string;
186
190
  table?: string;
187
191
  title?: string;
188
192
  props?: SMDProp[];
193
+ indexes?: SMDIndex[];
189
194
  subsets?: {
190
195
  [subset: string]: T[];
191
196
  };
@@ -352,7 +357,6 @@ export type MigrationColumn = {
352
357
  export type MigrationIndex = {
353
358
  columns: string[];
354
359
  type: "unique" | "index";
355
- name?: string;
356
360
  };
357
361
  export type MigrationForeign = {
358
362
  columns: string[];