I can't access the singleton dictionary correctly from my custom resource

Godot Version

4.3

Question

I have a SkillDB.gd, a singleton database file for my character skills:

extends Node

enum Skill_id { INSIGHT, POWER_SLASH, BASH }

const skill_dictionary : Dictionary = {
	"Insight" : Skill_id.INSIGHT,
	"Power Slash" : Skill_id.POWER_SLASH,
	"Bash" : Skill_id.BASH
}

const skill_res : Dictionary = {
	Skill_id.INSIGHT : "res://Skills/Insight.tres",
	Skill_id.POWER_SLASH : "res://Skills/Power_Slash.tres",
	Skill_id.BASH : "res://Skills/Bash.tres"
}

And I have made my skill class for custom resources as the following:

extends Resource

class_name SkillClass

@export var name: String
@export var power: int
@export var cost: int
@export var accuracy: int
@export var active: bool
@export var description: String

@export var skill_id : SkillDB.Skill_id

func _ready():
	_set_skill_id()

func _set_skill_id():
	skill_id = SkillDB.skill_dictionary[name]

func get_skill_id() -> SkillDB.Skill_id :
	return skill_id

The _set_skill_id() method is called to initialize the skill_id accordingly to the SkillDB.
However when I checked the result, the skill_id is always set to 0 and not to the skill I created the resource for.
Why is this happening?

Resources do not call _ready()

Thank you for the comment.
I found another way around and changed my code as the following:

extends Resource

class_name SkillClass

@export var skill_id : SkillDB.Skill_id

@export var name: String :
	set(value):
		name = value
		_set_skill_id()
@export var power: int
@export var cost: int
@export var accuracy: int
@export var active: bool
@export var description: String

func _set_skill_id() -> void:
	skill_id = SkillDB.skill_dictionary[name]

But somehow, this code only makes my second skill_id correctly to 1, and the third skill is still set to 0.
The only way I can work this around is by calling the setter function everytime I load the skill resource to some other node, but I don’t want it to be this way.
I want the skill_id to be set when the resource is first created.

You basically have two separate references to the same thing - one with the enum, and one with the name String.
I would suggest you to do this reference only once - ideally the enum version of it to keep it type safe.
Then if you need the name String somewhere in your code, you can retrieve it with a getter, don’t bother with the setter.