Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pgsql #51

Merged
merged 25 commits into from
Jul 15, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
911835e
started schema migration from MySQL to PostgreSQL
sheshenia May 26, 2022
2463fcf
changes MySQL -> PostgreSQL prepared statements ? -> $1...
sheshenia May 26, 2022
244f114
continue queries migration MySQL -> PostgreSQL
sheshenia May 27, 2022
f37203b
triggers added to update_at, cli added postgreSQL
sheshenia May 27, 2022
be84b01
migrating queue, need deep analyse ClearQueue of UPDATE query
sheshenia May 27, 2022
283a3e8
solving bugs and testing fails, TODO TestQueue/notnow
sheshenia May 27, 2022
fdef433
tests pass ok
sheshenia May 27, 2022
433fe78
PostgreSQL added
sheshenia May 27, 2022
8f55319
PostgreSQL added fix gofmt
sheshenia May 29, 2022
42a3e2d
Update README.md
sheshenia Jun 3, 2022
2e792de
Update storage/postgresql/schema.sql
sheshenia Jun 3, 2022
657ff26
Update storage/postgresql/schema.sql
sheshenia Jun 3, 2022
9f6a7a9
Update storage/postgresql/postgresql.go
sheshenia Jun 4, 2022
98ea9a5
started
sheshenia Jun 5, 2022
fe23b5b
pgsql
sheshenia Jun 5, 2022
5a1417e
Merge branch 'micromdm:main' into main
sheshenia Jun 6, 2022
f388813
pgsql update fixed. Ok tested on real devices. Without "deleter" func…
sheshenia Jun 6, 2022
362b0a3
mysql deleter functionality
sheshenia Jun 7, 2022
ed36ad1
pgsql deleter functionality. todo tests
sheshenia Jun 7, 2022
9cb344b
pgsql deleter tests and docs
sheshenia Jun 7, 2022
1300373
typos fix
sheshenia Jun 7, 2022
94533a6
conflicts mysql - pgsql solved
sheshenia Jun 21, 2022
e986d1d
Merge remote-tracking branch 'upstream/main'
sheshenia Jun 21, 2022
d2a274c
Update storage/mysql/mysql.go
sheshenia Jul 15, 2022
726b2be
on conflict update time now
sheshenia Jul 15, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
pgsql deleter tests and docs
  • Loading branch information
sheshenia committed Jun 7, 2022
commit 9cb344b527cfeb55d8f4ed79d489910fe6f2c2a0
17 changes: 14 additions & 3 deletions docs/operations-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,23 @@ The `-storage`, `-dsn`, & `-storage-options` flags together configure the storag

* `-storage file`

Configures the `file` storage backend. This manages enrollment and command data within plain filesystem files and directories. It has zero dependencies and should run out of the box. The `-dsn` flag specifies the filesystem directory for the database.
Configures the `file` storage backend. This manages enrollment and command data within plain filesystem files and directories. It has zero dependencies and should run out of the box. The `-dsn` flag specifies the filesystem directory for the database. The `file` backend has no storage options.

*Example:* `-storage file -dsn /path/to/my/db`

#### mysql storage backend

* `-storage mysql`

Configures the MySQL storage backend. The `-dsn` flag should be in the [format the SQL driver expects](https://github.com/go-sql-driver/mysql#dsn-data-source-name). Be sure to create your tables with the [schema.sql](../storage/mysql/schema.sql) file that corresponds to your NanoMDM version. Also make sure you apply any schema changes for each updated version (i.e. execute the numbered schema change files). MySQL 8.0.19 or later is required.
Configures the MySQL storage backend. The `-dsn` flag should be in the [format the SQL driver expects](https://github.com/go-sql-driver/mysql#dsn-data-source-name). Be sure to create your tables with the [schema.sql](../storage/mysql/schema.sql) file that corresponds to your NanoMDM version. Also make sure you apply any schema changes for each updated version (i.e. execute the numbered schema change files). MySQL 8.0.19 or later is required.

*Example:* `-storage mysql -dsn nanomdm:nanomdm/mymdmdb`

Options are specified as a comma-separated list of "key=value" pairs. The mysql backend supports these options:
* `delete=1`, `delete=0`
* This option turns on or off the command and response deleter. It is disabled by default. When enabled (with `delete=1`) command responses, queued commands, and commands themselves will be deleted from the database after enrollments have responded to a command.

*Example:* `-storage mysql -dsn nanomdm:nanomdm/mymdmdb -storage-options delete=1`

#### pgsql storage backend

* `-storage pgsql`
Expand All @@ -64,6 +69,12 @@ Configures the PostgreSQL storage backend. The `-dsn` flag should be in the [for

*Example:* `-storage pgsql -dsn nanomdm:nanomdm/pgmdmdb`

Options are specified as a comma-separated list of "key=value" pairs. The pgsql backend supports these options:
* `delete=1`, `delete=0` or `delete=true`, `delete=false`
* This option turns on or off the command and response deleter. It is disabled by default. When enabled (with `delete=1`) command responses, queued commands, and commands themselves will be deleted from the database after enrollments have responded to a command.

*Example:* `-storage pgsql -dsn nanomdm:nanomdm/pgmdmdb -storage-options delete=true`

#### multi-storage backend

You can configure multiple storage backends to be used simultaneously. Specifying multiple sets of `-storage`, `-dsn`, & `-storage-options` flags will configure the "multi-storage" adapter. The flags must be specified in sets and are related to each other in the order they're specified: for example the first `-storage` flag corresponds to the first `-dsn` flag and so forth.
Expand Down
15 changes: 13 additions & 2 deletions storage/pgsql/queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func TestQueue(t *testing.T) {
t.Fatal("PostgreSQL DSN flag not provided to test")
}

storage, err := New(WithDSN(*flDSN))
storage, err := New(WithDSN(*flDSN), WithDeleteCommands())
if err != nil {
t.Fatal(err)
}
Expand All @@ -96,5 +96,16 @@ func TestQueue(t *testing.T) {
t.Fatal(err)
}

test.TestQueue(t, deviceUDID, storage)
t.Run("WithDeleteCommands()", func(t *testing.T) {
test.TestQueue(t, deviceUDID, storage)
})

storage, err = New(WithDSN(*flDSN))
if err != nil {
t.Fatal(err)
}

t.Run("normal", func(t *testing.T) {
test.TestQueue(t, deviceUDID, storage)
})
}