| Age | Commit message (Collapse) | Author |
|
The Meta method returns new instance of [Meta] based on the current
client driver and kind arugment.
While at it, update comments on most methods to use adjectives.
|
|
With help of spdxconv tool [1], we able to bulk update all files license
and copyright format to comply with SPDX formats.
[1] https://kilabit.info/project/spdxconv/
|
|
Accepting the [http.FileSystem] means that the parameter can receive an
instance of [embed.FS], but in most cases, it will fail.
Case example, when we embed SQL files for migration under
"db/migration" using the "go:embed" directive,
//go:embed db/migration/*.sql
var DBMigrationFS embed.FS
and then call the [Migrate] function, it will not found any ".sql" files
inside the "/" directory because the files is stored under
"db/migration/" prefix (also there is no "/" when using embed.FS).
|
|
HTTP request now implicitly create request with context.
Any false positive related to not closing HTTP response body has been
annotated with "nolint:bodyclose".
In the example code, use consistent "// Output:" comment format, by
prefixing with single space.
Any comment on code now also prefixing with single space.
An error returned without variables now use [errors.New] instead of
[fmt.Errorf].
Any error returned using [fmt.Errorf] now wrapped using "%w" instead of
"%s".
Also, replace error checking using [errors.Is] or [errors.As], instead
of using equal/not-equal operator.
Any statement like "x = x OP y" now replaced with "x OP= y".
Also, swap statement is simplified using "x, y = y, x".
Any switch statement with single case now replaced with if-condition.
Any call to defer on function or program that call [os.Exit], now
replaced by calling the deferred function directly.
Any if-else condition now replaced with switch statement, if possible.
|
|
There are several reasons that why we move from github.com.
First, related to the name of package.
We accidentally name the package with "share" a common word in English
that does not reflect the content of repository.
By moving to other repository, we can rename it to better and unique
name, in this "pakakeh.go".
Pakakeh is Minang word for tools, and ".go" suffix indicate that the
repository related to Go programming language.
Second, supporting open source.
The new repository is hosted under sourcehut.org, the founder is known
to support open source, and all their services are licensed under AGPL,
unlike GitHub that are closed sources.
Third, regarding GitHub CoPilot.
The GitHub Terms of Service [1], allow any public content that are hosted
there granted them to parse the content.
On one side, GitHub helps and flourish the open source, but on another
side have an issues regarding scraping the copyleft license [2].
[1]: https://docs.github.com/en/site-policy/github-terms/github-terms-of-service#4-license-grant-to-us
[2]: https://githubcopilotinvestigation.com
|
|
|
|
Since Go 1.16, the ioutil package has been deprecated.
This changes replace any usage that use functions from ioutil package
with their replacement from package os or package io.
|
|
In the method Migrate() we add parameter "tableMigration" which define
the name of table where the state of migration will be saved.
If its empty default to "_migration".
|
|
On table that contains foreign key, truncate without cascade may cause
the method fail.
Also, since TruncateTable is, and should be only, used on testing, any
identity columns, for example serial, should be reset back to its initial
value. On PostgreSQL this means the truncate table is with
"RESTART IDENTITY".
|
|
There is probably a regression in Go that cause ioutil.ReadAll return
io.EOF, while it should not, because the documentation said that
A successful call returns err == nil, not err == EOF.
But in this, using http.FileSystem, the ioutil.ReadAll now return EOF
and we need to check it to make the migration can run without an error.
|
|
Previously, if the last migrated file name not found on the migration
directory, we start executing migration start from the first file.
This changes this behaviour to not run any migration at all.
Since we cannot return it as an error, we only log it. In the future
we may return it.
|
|
This will allow deleting the record by filename instead of requiring
all columns.
|
|
If we pass nil pointer of type to fs, the if condition will not true
and this cause panic because fs is not nil.
|
|
If case the file-system argument is not provided, the function will
assume that the migration script is stored in the MigrationDir which
defined in ClientOptions.
|
|
While at it, rename the function from "New" to "NewClient" for clarity.
|
|
|
|
|
|
The Migrate method migrate the database using list of SQL files inside
a directory.
Each SQL file in directory will be executed in alphabetical order based on
the last state.
The state of migration will be saved in table "_migration" with the SQL
file name that has been executed and the timestamp.
|
|
|