Skip to content

Commit ab5c35c

Browse files
committed
🎨 Improve file structure
1 parent 29d399c commit ab5c35c

18 files changed

+370
-370
lines changed

demo/go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ module demo
33
go 1.17
44

55
require github.com/DGuang21/goMigration v0.0.0-20220219155357-b3bbc085e41e
6+
7+
replace github.com/DGuang21/goMigration v0.0.0-20220219155357-b3bbc085e41e => ../

demo/go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +0,0 @@
1-
github.com/DGuang21/goMigration v0.0.0-20220219155357-b3bbc085e41e h1:NGu5QZEdOB1/OB7mfoU5y6bi++S4dJuJyRu9lCK0Nh8=
2-
github.com/DGuang21/goMigration v0.0.0-20220219155357-b3bbc085e41e/go.mod h1:h4VLo8vlX+jFXC7nEfANtEdsUeIYCbWFHZR/SlT+J4k=
File renamed without changes.
Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
11
package migration
22

3+
type migration struct{}
4+
5+
var (
6+
Migration = migration{}
7+
)
8+
39
/**
410
* @Description:
511
* @param tableName
612
* @param version
713
* @param fields
814
* @auth: daguang
915
*/
10-
func Create(tableName string, fields ...func(table *MigrationTable)) {
16+
func (m *migration) Create(tableName string, fields ...func(table *MigrationTable)) {
1117
if tableName == "" {
1218
panic("table can't be null")
1319
}
1420
if len(fields) > 0 {
1521
for _, fieldFunc := range fields {
1622
a := MigrationTable{
1723
table: &MigrationAttributes{
18-
tableName: tableName,
24+
tableName: tableName,
1925
},
2026
}
2127
fieldFunc(&a)
@@ -29,11 +35,11 @@ func Create(tableName string, fields ...func(table *MigrationTable)) {
2935
* @param tableName
3036
* @auth: daguang
3137
*/
32-
func DropIfExists(tableName string) {
38+
func (m *migration) DropIfExists(tableName string) {
3339

3440
}
3541

36-
func Drop(tableName string) {
42+
func (m *migration) Drop(tableName string) {
3743

3844
}
3945

@@ -44,7 +50,7 @@ func Drop(tableName string) {
4450
* @param fields
4551
* @auth: daguang
4652
*/
47-
func UpdateTable(tableName string, fields ...func(table *MigrationTable)) {
53+
func (m *migration) UpdateTable(tableName string, fields ...func(table *MigrationTable)) {
4854
if tableName == "" {
4955
panic("table can't be null")
5056
}
@@ -56,6 +62,6 @@ func UpdateTable(tableName string, fields ...func(table *MigrationTable)) {
5662
}
5763
}
5864

59-
func ReName(tableName string, newName string) {
65+
func (m *migration) ReName(tableName string, newName string) {
6066

6167
}

migration/migration_field_digital.go

Lines changed: 0 additions & 150 deletions
This file was deleted.

migration/migration_field_text.go

Lines changed: 0 additions & 100 deletions
This file was deleted.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (m *MigrationAttributes) Change() {
6363

6464
// Index 添加一个单独的 index
6565
func (m *MigrationAttributes) Index(indexName string) *MigrationAttributes {
66-
m.indexFields = append(m.indexFields,[]string{m.result[len(m.result)-1].field})
67-
m.indexName = append(m.indexName,indexName)
66+
m.indexFields = append(m.indexFields, []string{m.result[len(m.result)-1].field})
67+
m.indexName = append(m.indexName, indexName)
6868
return m
69-
}
69+
}

0 commit comments

Comments
 (0)