Commit graph

209 commits

Author SHA1 Message Date
Ankush Menat
b4fe7223c1 fix(postgres): treat LockNotAvailable as timeout
It's a lock timeout in a way.
2024-02-29 18:04:05 +05:30
Akhil Narang
3f1e19de85
refactor(treewide): enable RUF rules
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-02-21 16:20:28 +05:30
Akhil Narang
26ae0f3460
fix: ruff fixes
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-02-07 17:04:31 +05:30
Ankush Menat
de9ac89748 style: re-format with ruff 2024-02-05 18:53:33 +05:30
David Arnold
94378b6566
chore: simplify frappe.connect and use site config for bootstrapping 2024-01-19 13:49:36 +01:00
David Arnold
7bec22e238
Merge remote-tracking branch 'origin/develop' into chore/cleanup-low-level-db-interface 2024-01-18 13:22:33 +01:00
David Arnold
9a1af12a41
chore: more concise code 2024-01-18 10:20:12 +01:00
David Arnold
bd357f41d3
feat: add defaults to db superuser prompt 2024-01-17 20:25:27 +01:00
David Arnold
f889d09d0b
fix: set defaults at the highest level interface 2024-01-17 18:59:34 +01:00
Akhil Narang
9b18289b33
fix: postgres uses double quotes for identifiers, especially if case-sensitive
(single quotes would force it to lowercase)

Also unconditionally create a new user while running tests - we're gonna be dropping the test site

Don't pass a `None` value to bench cli

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-01-16 12:35:01 +05:30
Akhil Narang
265c0b0e01
fix(drop-site): set db root credentials in frappe.flags like how new-site is done
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-01-16 12:35:01 +05:30
Akhil Narang
f876aa385c
fix(setup_db): use the correct user
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-01-16 12:35:01 +05:30
Akhil Narang
1e6eeba9b7
fix: add in missing logic, add in a test for creating a site with a specific user
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-01-16 12:35:01 +05:30
Akhil Narang
c721fcf8c4
refactor: allow setting a db user name different from the database name
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-01-16 12:35:01 +05:30
David Arnold
3fa76b827c
chore: name current db handle properly 2024-01-14 17:14:21 +01:00
Ankush Menat
4996b8ac7b refactor: postgres version check 2023-12-27 16:12:40 +05:30
hhharsha36
445da4319b
fix: error - permission denied for schema public from Postgres >= 15 during initial DB setup (#23799)
Error from Postgres:
ERROR:  permission denied for schema public at character 14

Error from Frappe:
psql:/home/frappe/frappe-bench/apps/frappe/frappe/database/postgres/framework_postgres.sql:72: ERROR:  permission denied for schema public

Error Causer:
Starting Postgres version >= 15, all users will have the `CREATE` permission revoked by default.

Fix:
Grant relevant privileges to the database in question for the user. In this case, DB owner privilege.

Note: the below two permission attempts were unsuccessful and still caused the same public schema permission error

GRANT USAGE, CREATE ON SCHEMA public TO {frappe.conf.db_name};
GRANT ALL ON SCHEMA public TO {frappe.conf.db_name}

References:
https://stackoverflow.com/questions/74110708/postgres-15-permission-denied-for-schema-public
https://stackoverflow.com/questions/67276391/why-am-i-getting-a-permission-denied-error-for-schema-public-on-pgadmin-4
2023-12-27 16:04:21 +05:30
Ankush Menat
2dfef73ae8
Merge pull request #22915 from akhilnarang/dont-extract-backup-unconditionally
perf: don't extract gzipped backups
2023-12-26 12:19:10 +05:30
Xiaoguang Sun
68d4a5ad82
Do not call begin in updatedb after syncing (#23934)
Do not call begin in updatedb after syncing as commit does it already.

Signed-off-by: Xiaoguang Sun <sunxiaoguang@gmail.com>
2023-12-26 12:12:19 +05:30
Akhil Narang
3fe840fb31
fix(postgres): make use of common helper
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-12-26 11:09:08 +05:30
Akhil Narang
012b0fdb7e
fix(postgres/setup): use gzip to get backup contents if the file is an archive
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-12-26 11:09:08 +05:30
Hussain Nagaria
8d2137c265 docs: consistent doc strings 2023-12-18 18:27:39 +05:30
barredterra
c35476256f refactor: simplify conditional logic
Command: `sourcery review --fix --enable de-morgan .`
2023-12-05 11:14:41 +01:00
Akhil Narang
fbc88a4d24
refactor(treewide): code cleanup
Drop redundant bool conversion

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-11-23 13:57:51 +05:30
Ankush Menat
d715b0ad31
Merge pull request #22804 from akhilnarang/non-nullable-fields
feat: allow setting fields as not nullable
2023-11-20 12:46:02 +05:30
Akhil Narang
ae9ae40bad
Merge pull request #23168 from blaggacao/refactor/centralize-python-shell-interface-for-database-binaries
refactor: give cli invocations of dbtools a dedicated interface
2023-11-17 17:02:41 +05:30
David Arnold
283e91fd43
fix: minor fixes
Co-authored-by: Akhil Narang <me@akhilnarang.dev>
2023-11-17 10:01:53 +01:00
Akhil Narang
e1bbcd73ab
fix: 0 is falsy, set correct defaults
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-11-16 16:14:50 +05:30
Akhil Narang
e3f6437245
fix(postgres): properly change nullability and default values
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-11-16 16:14:50 +05:30
David Arnold
5b33608fe3
fix: shell escaping in execute_in_shell helper 2023-11-16 10:52:11 +01:00
Akhil Narang
b901f37267
feat(postgres/schema): add support for setting fields as not-nullable
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-11-16 14:51:57 +05:30
Akhil Narang
806748b063
chore: simplify transaction handling
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-11-16 14:51:57 +05:30
Akhil Narang
e41fa2dfc7
feat: migrate columns to be non-nullable if required
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-11-16 14:51:57 +05:30
Akhil Narang
6550e0769b
feat: allow ignoring implicit commit warning
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-11-16 14:51:57 +05:30
David Arnold
0dc2a9c2f3
refactor: normalize function signature 2023-11-10 15:12:59 +01:00
David Arnold
b2f9ff09aa
feat(db): boostrap only option if resource management is exogenous
The database resource management including privileges granting can be
done by external secops. It can be undesirable to grant the grant option
to the framework user.

This commit implements the possibility to remove user resource
management from frappe entirely and only boostrap the database with its
target user.
2023-11-09 17:11:39 +01:00
David Arnold
40a2daf84c
chore: give cli invocations of dbtools a dedicated interface 2023-11-09 12:14:41 +01:00
David Arnold
d5a390cd95
chore: compose postgres conn settings in the same way as with mariadb 2023-11-09 10:00:24 +01:00
Ankush Menat
0d5f28d569 feat: rename custom field 2023-09-25 12:25:28 +05:30
Ankush Menat
730e906dfd
refactor!: remove implicit primary key from logs (#22209) 2023-08-26 16:01:47 +05:30
mergify[bot]
fd10ab25cc
Merge pull request #22003 from gavindsouza/refactor-doc-bits
refactor: Use single query to delete child rows on doc.save
2023-08-11 06:45:07 +00:00
Gavin D'souza
28e657b603
fix: Check if fieldtype in set rather than str comparison 2023-08-11 11:45:42 +05:30
barredterra
88c8baa9ee refactor: for append to extend, merge list extend
Replace a for append loop with list extend.
Create the list with values instead of creating
an empty list and extending it with another list.
2023-08-09 13:25:39 +02:00
David Arnold
a926e64ec9
fix: procure db config from single authority (#21578)
* fix: procure db config from single authority

ensures that configuration is uniformely procured from local.conf
instead of making use of hard to audit multilevel fallback logic

Implementation Note:
- `get_db(host, port, user, password)` was stripped of any optional
  argument and therefrom all errors where fixed.
- All occurances of `grep 'frappe.db.db_'` where changed to
  `frappe.conf.db_`

* fix: revert unnecessary breaking changes
2023-07-24 10:48:29 +05:30
David Arnold
6b2bb9a2ab
fix: add env overrides for service orchestration (#21577)
This avoids having to manipulate config files in brittle bash
entrypoints that need to react to dynamic service discovery.

This significantly improves the operability of various bench sites.
2023-07-14 11:39:01 +05:30
Ankush Menat
4104e7d733
feat: show db table utilization on doctype (#21193)
* feat: show db table utilization on doctype

* fix: nicer error message with docs
2023-05-31 16:28:44 +05:30
Ritwik Puri
d099c9376b
feat(minor): db.get_column_type for postgres (#21125) 2023-05-26 16:03:28 +05:30
Sagar Vora
4ea39d1a68
chore!: drop device support from session (#18729)
* chore!: drop device support from session

* chore: remove `session_expiry_mobile` field

* fix: remove extra `%s`
2022-12-05 16:37:32 +05:30
Ankush Menat
ce360b6fce feat: Set default SQL statement timeouts 2022-11-08 14:51:43 +05:30
Ankush Menat
8cca50bf26
refactor: remove naming case feature (#18672)
This has never worked since 2016... which can mean two things:
- No one really uses this.
- If I fix this now suddenly people will find different behaviour in
  naming because `name_case` is selected in some doctypes (but never
  tested)
2022-10-31 11:23:49 +05:30