Commit graph

197 commits

Author SHA1 Message Date
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
Ankush Menat
f96505fae0 feat: wrap read only mode SQL errors 2022-09-09 17:34:44 +05:30
Himanshu
3faaf5f361
Merge branch 'develop' into merge_translated_doctypes 2022-08-12 13:10:49 +01:00
Gavin D'souza
91a47c2602 fix: Deprecate setup help database APIs
APIs have been unused since ~v4/6? Don't see any need to keep them in.
2022-08-12 12:52:19 +05:30
hrwx
b01929405d refactor: translatable doctypes 2022-08-05 21:38:10 +01:00
Ritwik Puri
cb6438158b
fix: don't use cache for sequence in mariadb (#17640)
* fix: don't use cache for sequence in mariadb

* chore: update sequence related comments
2022-07-27 22:46:56 +05:30
Gavin D'souza
bcfa8c276e fix: Set default port attribute for Database classes
db.default_port wil be available as a class attribute to hold defaults
for DB types.

Usage: frappe.conf.db_port or frappe.db.default_port
Why: I couldn't run the mariadb command because the defaults aren't set
for my system. server is remote / containerized. Setting port in
equivalent mysql command fixes this.
2022-07-22 13:16:26 +05:30
Gavin D'souza
1a610e135d fix(db): Use sentinel object for default values paramters 2022-07-22 12:11:01 +05:30
gavin
43f378d848
Merge branch 'develop' into mariadb-client-refactor 2022-07-07 16:00:38 +05:30
Ankush Menat
5d2aedc698 fix(postgres): end transaction before DDL
closes https://github.com/frappe/frappe/issues/17210
2022-07-05 17:43:02 +05:30
Gavin D'souza
71b5c77e6e Merge branch 'develop' of github.com:frappe/frappe into mariadb-client-refactor 2022-07-05 14:55:02 +05:30
Ankush Menat
261fbfcd11
Revert "fix(doc)!: Always cast datetime, date and time fields"
Revert "fix(doc)!: Always cast datetime, date and time fields (#15891)"

This reverts commit d7789ab6ff.
2022-07-05 13:43:32 +05:30
Himanshu
d7789ab6ff
fix(doc)!: Always cast datetime, date and time fields (#15891)
### BREAKING CHANGE
#### Datetime, Date and Time fields will always be cast to respective objects in `setattr`, this will ensure uniformity while accessing the values, no more `getdate`, `get_datetime`, `to_timedelta` wrapper.
- While importing data, the framework does check for `set_only_once`.
- In normal case scenarios, this will work flawlessly since most date fields might not be set_only_once.
- But in Subscription, the date field is set to `set_only_once` and in `after_insert`, `document.save` is called, and while doing so, `set_only_once` is checked [here](1944a547f9/frappe/model/document.py (L566)).
-This works fine if the data imported is in the correct format.
- If the date's data is not in the correct format, the framework throws an error.
- for eg `06-02-2022 00:00:00 != 06-02-2022`
- fixes [Issue/#15370](https://github.com/frappe/frappe/issues/15370)

> no-docs
2022-07-05 07:07:16 +00:00