Sync table error if create custom index key #1182

Open
opened 2019-01-03 02:23:41 +00:00 by appleboy · 2 comments
Member

Create a custom index key on a table:

				if _, err := x.Exec("CREATE INDEX ll_idx on machine USING gist(ll_to_earth(lat, lng));"); err != nil {
					log.Fatal().Err(err).Msgf("can't index for gist lat lng")
				}

output the following errors after restarting service:

error="sync database struct error: Unknown col ll_to_eart in index ll_idx of table machine, columns [id name lat lng created_at updated_at]"

source code:

	if err = x.StoreEngine("InnoDB").Sync2(tables...); err != nil {
		return fmt.Errorf("sync database struct error: %v", err)
	}

	m := migrate.New(x, migrate.DefaultOptions, migrations)
	if err = m.Migrate(); err != nil {
		return fmt.Errorf("migrate: %v", err)
	}
Create a custom index key on a table: ```go if _, err := x.Exec("CREATE INDEX ll_idx on machine USING gist(ll_to_earth(lat, lng));"); err != nil { log.Fatal().Err(err).Msgf("can't index for gist lat lng") } ``` output the following errors after restarting service: ``` error="sync database struct error: Unknown col ll_to_eart in index ll_idx of table machine, columns [id name lat lng created_at updated_at]" ``` source code: ```go if err = x.StoreEngine("InnoDB").Sync2(tables...); err != nil { return fmt.Errorf("sync database struct error: %v", err) } m := migrate.New(x, migrate.DefaultOptions, migrations) if err = m.Migrate(); err != nil { return fmt.Errorf("migrate: %v", err) } ```
Owner

Why ll_to_eart not ll_to_earth?

Why `ll_to_eart` not `ll_to_earth`?
lunny modified the milestone from 0.8 to 0.8.2 2019-10-21 03:48:53 +00:00
lunny modified the milestone from 0.8.2 to 1.1.1 2020-02-21 02:45:09 +00:00
Owner

Sync2 cannot work with index manually creation.

Sync2 cannot work with index manually creation.
lunny modified the milestone from 1.1.1 to (deleted) 2021-06-09 01:54:13 +00:00
lunny referenced this issue from a commit 2021-06-09 01:54:45 +00:00
lunny referenced this issue from a commit 2021-06-12 09:13:40 +00:00
lunny referenced this issue from a commit 2021-06-12 12:37:54 +00:00
lunny referenced this issue from a commit 2021-07-06 09:07:16 +00:00
lunny removed this from the (deleted) milestone 2023-07-26 01:23:28 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: xorm/xorm#1182
No description provided.