Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
DataSmith
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
apps
DataSmith
Commits
70699ed5
Commit
70699ed5
authored
9 months ago
by
Sigmund, Dominik
Browse files
Options
Downloads
Patches
Plain Diff
Small fix for the basic add
parent
b39b3aa7
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#82657
canceled
9 months ago
Stage: build
Stage: scan
Stage: release
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+9
-1
9 additions, 1 deletion
README.md
commands/add.go
+5
-5
5 additions, 5 deletions
commands/add.go
main.go
+7
-1
7 additions, 1 deletion
main.go
with
21 additions
and
7 deletions
README.md
+
9
−
1
View file @
70699ed5
...
...
@@ -32,7 +32,15 @@ ds init
### Add a new table
```
bash
ds add table
"Table Name"
ds add
```
```
bash
ds add
"Table Name"
```
```
bash
ds add
users
--model
'{"fields":[{"name":"id","type":"INT","primary_key":true,"auto_increment":true,"not_null":true},{"name":"name","type":"VARCHAR(255)","unique":true,"not_null":true},{"name":"email","type":"VARCHAR(255)","unique":true,"not_null":true},{"name":"created_at","type":"DATETIME","not_null":true,"default_value":"CURRENT_TIMESTAMP"}]}'
```
## Contributing
...
...
This diff is collapsed.
Click to expand it.
commands/add.go
+
5
−
5
View file @
70699ed5
...
...
@@ -299,18 +299,18 @@ func promptForTableModel() TableModel {
utils
.
PromptIfEmpty
(
&
field
.
Name
,
"Enter field name: "
)
field
.
Type
=
promptForFieldType
()
field
.
PrimaryKey
=
utils
.
PromptForBool
(
"Is this a primary key? (y/n): "
)
field
.
PrimaryKey
=
utils
.
PromptForBool
(
"Is this a primary key? (y/n): "
)
// TODO: use SelectMenu
if
!
field
.
PrimaryKey
{
utils
.
PromptIfEmpty
(
&
field
.
ForeignKey
,
"Enter foreign key (leave empty if not applicable): "
)
}
field
.
Unique
=
utils
.
PromptForBool
(
"Is this field unique? (y/n): "
)
field
.
NotNull
=
utils
.
PromptForBool
(
"Is this field not null? (y/n): "
)
field
.
AutoIncrement
=
utils
.
PromptForBool
(
"Is this field auto-increment? (y/n): "
)
field
.
Unique
=
utils
.
PromptForBool
(
"Is this field unique? (y/n): "
)
// TODO: use SelectMenu
field
.
NotNull
=
utils
.
PromptForBool
(
"Is this field not null? (y/n): "
)
// TODO: use SelectMenu
field
.
AutoIncrement
=
utils
.
PromptForBool
(
"Is this field auto-increment? (y/n): "
)
// TODO: use SelectMenu
field
.
DefaultValue
=
utils
.
PromptForString
(
"Enter default value (leave empty if not applicable): "
)
fields
=
append
(
fields
,
field
)
if
!
utils
.
PromptForBool
(
"Do you want to add another field? (y/n): "
)
{
if
!
utils
.
PromptForBool
(
"Do you want to add another field? (y/n): "
)
{
// TODO: use SelectMenu
break
}
}
...
...
This diff is collapsed.
Click to expand it.
main.go
+
7
−
1
View file @
70699ed5
...
...
@@ -36,13 +36,19 @@ func main() {
case
"add"
:
var
tableName
,
model
string
args
:=
os
.
Args
[
2
:
]
for
i
,
arg
:=
range
args
{
for
i
:=
0
;
i
<
len
(
args
);
i
++
{
arg
:=
args
[
i
]
if
arg
==
"--model"
&&
i
+
1
<
len
(
args
)
{
model
=
args
[
i
+
1
]
i
++
// Skip the next argument since it's the model value
}
else
if
!
strings
.
HasPrefix
(
arg
,
"--"
)
{
tableName
=
arg
}
}
if
tableName
==
""
{
fmt
.
Println
(
"Usage: ds add <tablename> [--model <json_model>]"
)
return
}
commands
.
Add
(
tableName
,
model
)
case
"version"
:
commands
.
Version
(
version
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment